esack Posted August 6, 2008 Share Posted August 6, 2008 I have a javascript/AJAX code that gets 3 drop down lists from a script on the server and displays them in the web page. If a selection is made the AJAX will populate again using the variables selected in the lists. I am having problems getting the selected value from the lists. Any help would be great. If it helps you can see the main parts of the code. Client: function getLabels(myfrom, first) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var lb1=""; var lb2=""; var lb3=""; lb1=myfrom.label1.selectedValue; //this does not work it gives undefined var url="matrix_details.php?id=<?php echo $colname__myProduct;?>&label1=" + lb1; xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } HTML: <td id="labelOptions"> hi </td> function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("labelOptions").innerHTML = xmlHttp.responseText; } } Server: PHP echo '<tr>'; echo ' <td align="right">'. $matrix->Fields('label1').'</td>'; echo ' <td>'; echo ' <select onchange="popLabels(document.myform)" name="label1" >'; echo ' <option value="">Select</option>'; while(!$matrix_products->EOF) { if(checkLabel($labelDes,$matrix_products->Fields($label))) { echo ' <option '; if($matrix_products->Fields($label) == $labels[$i-1]) echo 'selected="selected" '; echo 'value="'.$matrix_products->Fields($label).'">'.$matrix_products->Fields($label); if($i == $priceLabel) echo ' - '.$matrix_products->Fields('price'); echo '</option>'; $labelDes[]=$matrix_products->Fields($label); } $matrix_products->MoveNext(); } echo ' </select></td></tr>'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.