Web Analytics Made Easy -
StatCounter Cookie question - CodingForum

Announcement

Collapse
No announcement yet.

Cookie question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cookie question

    Pulling data from a database.
    The drawn data comes paired, from two fields in the same database.

    Example source code:
    Code:
    var emps = [
    		['American Studies','AMST'],['Anglican Studies','ANGL']];
    The scenario: the values of [0] are displayed in a listbox. (American Studies & Anglican Studies)
    The goal is to have the corresponding information (AMST & ANGL) appear in an <INPUT> box based upon the listbox selection.

    I'm able to write either (AMST & ANGL) using <SPAN> & <DIV> tags. But I can't get (AMST & ANGL) to appear in an <INPUT> tag's value.

    Didn't get any response on my first posting; thought I'd re-submit it. I'd like to know if it's even possible. Haven't found a single tutorial on placing known data into the value of <INPUT> tags.

    innerHTML doesn't seem to work either.

  • #2
    Do you mean something on these lines?

    PHP Code:
    <form name="f1">
    <
    select name="s1" onchange="test(this)"></select>
    <
    input type="text" name="t1">
    </
    form>

    <
    script type="text/javascript">

    var 
    emps = [
    [
    'American Studies','AMST'],['Anglican Studies','ANGL']
    ];
            
    document.f1.s1[document.f1.s1.length] = new Option("Choose",null)
            
    for(var 
    i=0;i<emps.length;i++){
    document.f1.s1[document.f1.s1.length] = new Option(emps[i][0],emps[i][0])
    }

    function 
    test(obj){
    if(
    obj.selectedIndex!=0){
    document.f1.t1.value=emps[obj.selectedIndex-1][1]
    }
    else{
    document.f1.t1.value=""
    }

    }
    </
    script
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

    Comment


    • #3
      Mr. J,

      That nailed it.

      Thank you for the support.

      Comment

      Working...
      X