Help - Search - Members - Calendar
Full Version: Code Troubleshooting
Zymic Webmaster Forums > Web Design & Development > Client Side Scripting > JavaScript
The Seventh Hokage
i have code to create a select list.

this select list is populated by db query

i have two pieces of code i need looked at to fix the problem

CODE
echo "<select name='LearnedJutsus' id='YourJutsu' onchange='return jutsu()' >";

    foreach($learnedJutsuInfo as $v)
    {

        echo "<option  value='$v'>$v</option>";


    }
    echo "</select></form>";



and
most importantly this one!

CODE
var selection=document.getElementById("x").options[document.getElementById("x").selectedIndex].value;


i did not write the above code it was donated to me but it seems to be not working correctly.

what i need is an explanation on how it works (which would be best since im foggy with jscript)or a fix for it

i basically need it to grab the selected option's information for later use in the program. this is a pivotal part of the system

any help appreciated.
Shubh Karman Singh
You can get the value by using the following code:

selection=document.getElementById('yourSelectBoxId').options[document.getElementById('yourSelectBoxId').selectedIndex].value;

It would give you the value of $v

Or you may try
selection=document.getElementById('yourSelectBoxId').value;
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.