Jump to content

Accessing the value of a dropdown box


wongadob
 Share

Recommended Posts

I am trying to access the value of the element selected in a Select Inputbox. Here is the PHP code I have

print"<br/><br/><label class = 'labels'>Allocate all site to</label><select class = 'inputbox' id = 'ReallocAll' name = 'ReallocAll' onchange='change_realloc_fm_all()'>";print "<option value = '0'> </option>"; $y=0;While ($y<$FMListCount){  print "<option value = '".$FMListID[$y]."'>".$FMListName[$y]."</option>";  $y+=1;}

This bit of code creates a list with a value that is a database ID of a user and that users actual name. They have been pre grabbed into an array. What I will do in the onchange event is to populate a large table of select input boxes further down the form to this default user. But my first step is to try and find that user number. Here is my Javascript code

function change_realloc_fm_all()//--------------------------------------------------------------------------------------------{var FMUserSelected = document.getElementById("ReallocAll");var FMUserID = FMUserSelected.value; result = confirm("Change user ID " + toString(FMUserID));}

But I am not getting a User ID value. Instead it just says 'Change user ID [object window] I am sure this code is correct? Can anybody tell me what I am doing wrong. When I have solved this. I will want to write the User ID into several Select inputbox's default values. Is that possibe to set by using say document.getElementById("myNewSelectInputbox").value=FMUserID Any help much appreciated

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...