Forum Moderators: coopster
something like:
in the header put
<SCRIPT language="JavaScript">
function submitform()
{
document.form1.submit();
}
</SCRIPT>
then for the body put
<form name="form1" method="post" action="<?pjp echo $_SERVER[PHP_SELF];?>">
<input type="checkbox" name="checkbox1" value="checkbox" onClick="javascript:submitform();">
</form>
should do the job
hughie
Like when you register for Hotmail and the part where you have to select your country... It will bring you to another page with details more connected to your country...
so similar to before
<?php
// DBASE CONECT HERE
//
if (isset($_POST['finalsubmit']))
{
// PROCEED TO NEXT FORM
}
else
{
if (isset($_POST['select1']) && $_POST['select1']!=0)
{
$result=mysql_query("SELECT * FROM states WHERE country_id=$_POST[select1] ");
$thestates='STATES <select name="states">';
while($row=mysql_fetch_array($result))
{
// RETURN DETAILS OF THE COUNTRY CHOSEN
$thestates.='<option value="'.$row[State_ID].'">'.$row[State].'</option>';
}
$thestates.='</select>';
}
}
?>
<html>
<head>
<SCRIPT language="JavaScript">
function submitform()
{
document.form1.submit();
}
</SCRIPT>
</head>
<body>
<form name="form1" method="post" action="<?php echo $_SERVER[PHP_SELF];?>">
<select name="select1" onChange="javascript:submitform();">
<option value="0" selected>Please Choose a Country</option>
<option value="1">UK</option>
<option value="2">USA</option>
</select>
<?php echo $thestates;?>
<Br><br>
<input type="submit" name="finalsubmit" value="FINAL SUBMIT">
</form>
</body></html>
when the person changes the select box the for will reload and pullout the states of the relevant country.
cheers hughie
What I want is to use a dropdown menu. It will have datas inside and when the user selects the data, it will fill the textfield below with data from database. And the value of the dropdown menu would be selected on the one the user clicks...
Like when you register for Hotmail and the part where you have to select your country... It will bring you to another page with details more connected to your country...
if you're looking for a way to have your form interact immediatly with the user (ie after he changes something), this is client side. for client side you need to use javascript / ecma script / vbscript or any scriptlanguage browsers support. please refer to the javascript forum for that.
php itself is server side and recieves no events or requests when a user changes the content of a dropdown menu (combobox). php could have eventually provided the page incl. specific scripts and their data, but that's before the page is displayed.