Help me to solve this
Posted: Thu Oct 30, 2008 5:23 pm
Now about this program.... I have selected two columns from the data base. in $row[0] test_id is there, and $row[1] user_id is there. In my program my requirement is whenever i select an option from the drop down menu the corresponding $row[1] i.e user_id should be displayed on the text field, which is outside select tag.. So for that i have used javascript... but as i am new to java script i dont know much about java script.. Please help me.....
Code: Select all
<?
$qry = "select test_id, user_id from QDescr_4Eval";
$result = mysql_query($qry);
?>
<script type = "text/javascript">
<!--
function send_value(form,u_id) {
document.form.user_id.value = u_id;
}
//-->
</script>
Code: Select all
<h2>Tests available for Evaluation</h2>
<td>
<? print "<select name='test_id' id='Test' class='' tabindex='14' ><option value = ''>(Test_id), (User_id)</option>";
while($row = mysql_fetch_row($result)) {
if($t_id == $row[0] && $u_id == $row[1]) {
;
}
else {
echo "<option value = $row[0] onselect = 'send_value(this.form, this.$row[1])'>$row[0]";
$t_id = $row[0];
$u_id = $row[1];
}
}
?>
</select>
<input type = "text" value = "" name = "user_id">
</td>
<td> </td>
<td>
<input type = 'submit' name = 'submit' value = 'Submit'></input>
</td>
</tr>
</form>