Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.