write option values in drop down menu in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vidurac
    New Member
    • Sep 2010
    • 1

    #1

    write option values in drop down menu in php

    dear all,
    I want to dynamicaly write option values in drop down list using php. i use following code to do it.

    var x = document.getEle mentById("x_Are aName").value;
    x.options[x.selectedIndex].text="text to display";

    but this is not working. pls anyone can help me?
  • Canabeez
    New Member
    • Jul 2009
    • 126

    #2
    Hello,

    not 100% sure but as I can remember ".text" is only supported by IE, try

    [code="javascrip t"]
    var select = document.getEle mentById('x_Are aName');
    select.options[select.selected Index].innerHTML = 'Some Text';
    [/code]

    Furthermore I didn't see any connection to PHP as you mentioned, guess this is more a JavaScript question. I would also sugest to rewrite the whole dropdown box instead of changing a single option value, and then set the desired selectedIndex.

    Hope this helps, good luck.

    Comment

    Working...