tekrscom Posted June 12, 2007 Share Posted June 12, 2007 Hi, I was wondering if it is possible to use something like Javascript to make it so you don't have to click the submit button on a form to make it submit, while using php and mysql. e.g. <HTML> <HEAD> </HEAD> <BODY> <FORM NAME="myform1" ACTION="" METHOD="POST"> <SELECT NAME="gold_id" onSelect="testSelect(this.form1)"> $query = mysql_query("SELECT gold_id FROM sites WHERE 1"); while ($row = mysql_fetch_array($query)) { echo '<option value="', $row[gold_id], '">', $row[gold_id], '</option>'; } </SELECT> </FORM> <BR> <BR> <SCRIPT LANGUAGE="JavaScript"> function testSelect(form1) { <?php echo ' <FORM NAME="myform2" ACTION="" METHOD="POST"> <SELECT NAME="list2" onSelect="testSelect(this.form2)"> '; $query = mysql_query("SELECT project FROM logs WHERE gold_id = '$_POST[gold_id]'"); while ($row = mysql_fetch_array($query)) { echo '<option value="', $row[project], '">', $row[project], '</option>'; } echo ' </SELECT> </FORM> '; ?> } </SCRIPT> </BODY> </HTML> If so, could someone help me out with my code, or point me in the right direction? Quote Link to comment https://forums.phpfreaks.com/topic/55305-submit-form-without-clicking-submit-button/ Share on other sites More sharing options...
The Little Guy Posted June 12, 2007 Share Posted June 12, 2007 <select name='myfield' onchange='this.form.submit()'> <option .... > ... </select> Quote Link to comment https://forums.phpfreaks.com/topic/55305-submit-form-without-clicking-submit-button/#findComment-273388 Share on other sites More sharing options...
tekrscom Posted June 12, 2007 Author Share Posted June 12, 2007 I tried it, but it's not working, here's what I did with my code... I tried a few other variances also, but to no avail. <form method="POST" action="MTES.php"> <select name="gold_id" onChange="this.form.submit()"> <option value=""> ... </option> <? include "connection.php"; $query = mysql_query("SELECT gold_id FROM sites WHERE 1"); while ($row = mysql_fetch_array($query)) { echo '<option value="', $row[gold_id], '">', $row[gold_id], '</option>'; } ?> </select> </form> EDIT: Nevermind, I fixed it, thank you very much for your help... I certainly appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/55305-submit-form-without-clicking-submit-button/#findComment-273401 Share on other sites More sharing options...
The Little Guy Posted June 12, 2007 Share Posted June 12, 2007 try changing this.form.submit() to javascript:this.form.submit(); Quote Link to comment https://forums.phpfreaks.com/topic/55305-submit-form-without-clicking-submit-button/#findComment-273404 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.