SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Populate multiple dropdown with same text in text area

    I am trying to populate exactly five dropdown menus and I want the same code to appear in the text area as selected from the dropdown menu. How do I go about doing this? i KNOW HERE THAT I HAVE DIFFERENT TEXT BUT I CAN CHANGE IT LATER BUT I NEED TO BE ABLE TO POPULATE THE TEXT CORRECTLY? I have some code work done on it. Can some one tweek it to get it working?


    <html>
    <head>
    <!-- prob
    -->
    <script>
    function get(eid) {
    var d = document;
    var r = d.getElementById(eid);
    return r;
    }

    function loadText(oRef) {
    var sglass = oRef[oRef.selectedIndex];
    var smetal = oRef[oRef.selectedIndex];
    var sfacade = oRef[oRef.selectedIndex];
    var sroof = oRef[oRef.selectedIndex];
    var sother = oRef[oRef.selectedIndex];

    var tglass = sglass.value;
    var tmetal = smetal.value;
    var tfacade = sfacade.value;
    var troof = sroof.value;
    var tother = sother.value;

    get('sTextA').value = tglass;
    get('sTextB').value = tmetal;
    get ('sTextC').value = tfacade;
    get ('sTextD').value = troof;
    get ('sTextE').value = tother;
    }
    </script>
    </head>
    <body>

    <form>

    <select
    onchange="loadText(this);">
    <option
    value = "">


    </option>

    <option
    value="
    As previously reported windows have mineral deposit stains which would require a chemical restoration to remove">

    Glass
    </option>
    <option
    value="Building facade is in need of power washing.">

    Facade</option>
    <option
    value="Exterior metal mullions are oxidized and in need of a chemical restoration">
    Metal</option>
    <option
    value="Tie back system on roof may not be ANSI-114 compliant">
    Roof</option>
    <option
    value="Caulking is showing signs of deteriation and is in need of replacement">
    Other
    </option>

    </select>
    <input type="text" style= "width: 700px"
    id="sTextA" />
    </form>

    <form>
    <select
    onchange="loadText(this);">

    <option
    value = "">


    </option>

    <option
    value="As previously reported windows have mineral deposit stains which would require a chemical restoration to remove">

    Glass
    </option>
    <option
    value="Building facade is in need of power washing.">

    Facade</option>
    <option
    value="Exterior metal mullions are oxidized and in need of a chemical restoration">
    Metal</option>
    <option
    value="Tie back system on roof may not be ANSI-114 compliant">
    Roof</option>
    <option
    value="Caulking is showing signs of deteriation and is in need of replacement">
    Other
    </option>
    </select>
    <input type="text" style= "width: 700px"
    id2="sTextB" />
    </form>


    <form>
    <select onchange="loadtext(this);">

    <option
    value = "">


    </option>

    <option
    value="
    As previously reported windows have mineral deposit stains which would require a chemical restoration to remove">

    Glass
    </option>
    <option
    value="Building facade is in need of power washing.">

    Facade</option>

    <option
    value="Exterior metal mullions are oxidized and in need of a chemical restoration">
    Metal</option>
    <option
    value="Tie back system on roof may not be ANSI-114 compliant">
    Roof</option>
    <option
    value="Caulking is showing signs of deteriation and is in need of replacement">
    Other
    </option>

    </select>
    <input type="text" style= "width: 700px"
    id3="sTextC" />
    </form>

    <form>
    <select onchange="loadtext(this);

    <option
    value = "">

    </option>

    <option
    value="
    As previously reported windows have mineral deposit stains which would require a chemical restoration to remove">

    Glass
    </option>
    <option
    value="Building facade is in need of power washing.">

    Facade</option>
    <option
    value="Exterior metal mullions are oxidized and in need of a chemical restoration">
    Metal</option>
    <option
    value="Tie back system on roof may not be ANSI-114 compliant">
    Roof</option>

    <option
    value="Caulking is showing signs of deteriation and is in need of replacement">
    Other
    </option>
    </select>
    <input type="text" style= "width: 700px"
    id4="sTextD" />
    </form>

    <form>
    <select onchange="loadtext(this);

    <option
    value = "">


    </option>

    <option
    value="
    As previously reported windows have mineral deposit stains which would require a chemical restoration to remove">

    Glass
    </option>

    <option
    value="Building facade is in need of power washing.">

    Facade</option>
    <option
    value="Exterior metal mullions are oxidized and in need of a chemical restoration">
    Metal</option>
    <option
    value="Tie back system on roof may not be ANSI-114 compliant">
    Roof</option>
    <option
    value="Caulking is showing signs of deteriation and is in need of replacement">
    Other
    </option>
    </select>
    <input type="text" style= "width: 700px"
    id4="sTextE" />
    </form>
    </body>
    </html>

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please use code tags to properly format your html/javascript code.

    I would do something like this:
    Code:
    function loadText(theSelect, theTextbox) {
      theTextbox.value = theSelect.value;
    }
    
    ...
    
    <select onchange="loadText(this, document.getElementById('sTextA'));">
    ....
    </select>
    <input type="text" id="sTextA" name="something" />
    
    <select onchange="loadText(this, document.getElementById('sTextB'));">
    ....
    </select>
    <input type="text" id="sTextB" name="something" />
    
    (etc)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •