Shoutbox

Help again with php - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Help again with php (/showthread.php?tid=76646)

Help again with php by YottabyteWizard on 08-09-2007 at 08:21 AM

Sorry to bother you again guys... but I really need to have this working for tomorrow.

The options of a select box are gathered from a table of mysql. And when an option is selected, copy the value of it to a text input.

The query is saved into a variable, but I need to get a certain row information from it... and I don't know how. I already went to php.net and other websites, but cant find the answer.

I currently have this:

code:
<html><head>

<script language="javascript">

function select(id) {


document.forma.docname.value=

}

</script>

</head><body>
<?php
require ('connect.php');
?>
<form name="forma">
Medicamento: <br>
<select name="medica" size=5 onselect="(select(this))";>
<?php
$db['query'] = mysql_query('SELECT * FROM doctores');
while ($db['process'] = mysql_fetch_assoc($db['query'])) {
echo ('<option value="'.$db["process"]["id"].'">'.$db["process"]["nombre"].'</option>');
}
mysql_close();
?>
</select>
<input type=text style="width:100px;" name="docname"><br>
</form>
</body></html>

Obviously the javascript part wont work, im stuck there. Any ideas?

Any help will be greatly appreciated.
RE: Help again with php by matty on 08-09-2007 at 01:36 PM

If you are trying to get the value of the currently selected option from a Select box you need to use this

code:
getId('medica').options[getId('medica').selectedIndex].value;

function getId(id) { return document.getElementById(id); }