Hi everyone,
I've an issue here. i want load the data from database and i want it appear at DOM select. what i had done,first i load data to hidden text and use a javascript load to DOM select. But the problem is i need to click on select textbox first before the data is appear and also other problem i can't select other option.here is my code.
PHP code.
<head><script type='text/javascript' src='script.js'></script></head>
<body>
<tr>
<td>
<input type='hidden' id='hiddenState' value='$custState' size='28'></td></tr>
<tr>
<td>
<select id='state' onClick='return retrieveOption();'>
<option value='apple'>Apple</option>
<option value='banana'>Banana</option>
<option value='car'>car</option>
<option value='mouse'>mouse</option>
</td>
</tr>
</body>
/#############################################
javascript code.
function retrieveOption(){
var var_State=document.getElementById("hiddenState").value;
var var_Option=document.getElementById("state");
for(var i=0;i<var_Option.length;i++){
if (var_Option[i].value==var_State)
{
var var_Text=var_Option[i].text;
var_Option[i].selected=true;
}
}
}
thank you.