Forum Moderators: open

Message Too Old, No Replies

Form is not posting

         

puckparches

10:10 pm on Aug 30, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have a link that open a window with a form and when the form is submitted the window will close.

I finally got a link to open a new window and I finally found out how to close that window. The problem is that the form is not submitting the information to the data base.

The link:


<A HREF="javascript:void(window.open('form.htm'))">Add</A><BR>

The form page:


<form method="POST" action="addtodb.php">
<input>
'
'
'
<input>
<input type="submit" value="Item Select Item" onClick="window.close()">
</form>

adtodb.php

$a_id =$_POST['id'];
$a_name = $_POST['name'];

$strSQL = "INSERT INTO table (id, name)
VALUES ('$a_id', '$a_name');
mysql_query($strSQL, $myConn) or die (mysql_error());
echo "<script>alert('" . $intIndex . " Added!');</script>";

Since I added the "onClick="window.close" the form is not passing the values. Why?

Thanks

tata668

10:49 pm on Aug 30, 2006 (gmt 0)

10+ Year Member



Try:

<form method="POST" action="addtodb.php">
<input>
'
'
'
<input>
<input type="submit" value="Item Select Item" onClick="submit();window.close()">
</form>

kaled

10:53 pm on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Presumably the window is being closed before the data is submitted. Try using setTimeOut() to delay closing the window by 250ms.

Kaled.

puckparches

11:09 pm on Aug 30, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



thank you!

puckparches

11:41 pm on Aug 30, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



It worked adding:

onClick="submit();window.close()">

Thank you!