Jump to content

submit form without clicking submit button


tekrscom

Recommended Posts

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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.