PDA

View Full Version : Help with pop-up on form submit



jaustill
12-19-2009, 06:49 PM
Script: DHTML Window widget
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/

I am trying to use the DHTML Window widget with a form to pop window.
I am trying to use the iframe example, but can not seem to get the code correct.
The window pops but the variables do not post. Below is what I am using.

This is the main page that calls the pop-up and sends the variables


<html>
<head>
<title>Order Processing System </title>
<link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="windowfiles/dhtmlwindow.js">
/***********************************************
* DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script>
function popchangeaction(myForm) {
var w = dhtmlwindow.open("changeaction", "iframe", "op-doad.php", "Change the action", "width=200px,height=200px,resize=1,scrolling=1,left=10px,top=10px");
}
</script>
</head>
<body>
<?php
$edit_time = date('M d Y g:iA', strtotime('now'));
$order_no = '987652';
print "<table>
<tr>
<td>Order No</td>
<td>action_code</td>
</tr>";
?>
<?php
print " <tr>
<td>$order_no</td>
<td>
<FORM target='_iframe-changeaction' action='op-doad.php' method='POST'><input type='hidden' value='$order_no' name='order_no'>
<select type='submit' name='action_code' onchange='popchangeaction(this)'><option value='' selected>blank</option>
<option value='selection1'>selection1</option>
<option value='selection2'>selection2</option>
</select>
</font></td></tr></table></form>';
?>
</body>
</html>


This is the page that should be in the popup and receive the posted variables


<html>
<head>
<title>TITLE</title>
</head>
<body>
<?php
$edit_time = date('M d Y g:iA', strtotime('now'));
$order_no = $_POST['order_no'];
$new_action_code = $_POST['action_code'];

echo'Your order has been submitted for processing.<br />';

echo'<br />';
echo'edit_time';
echo'<br />';
echo $edit_time;
echo'<br />';
echo'order_no';
echo'<br />';
echo $order_no;
echo'<br />';
echo'action_code';
echo'<br />';
echo $new_action_code;
echo'<br />';

echo 'The database has been updated!';
?>

</body>
</html>

jaustill
12-20-2009, 06:01 AM
I may have solved my problem, I rewrote my onChange from
this


onchange='popchangeaction(this)'

to this


onChange='submit(popchangeaction(this))'

It works perfect now, however I am a beginner coder.

Did I do this correctly or is it a fluke that it works and will cause me problems with browsers other than Win IE.

ddadmin
12-20-2009, 08:07 AM
Are you trying to set up a form whereby when it's submitted, the results load in the DHTML Window? Generally for form submission there aren't that many cross browser issues, so if it works in Win IE, it should generally work in other browsers too. But we would need to see the code behind popchangeaction() to know if there are any issues.

jaustill
12-20-2009, 03:58 PM
Yes, I am trying to set up a form that when it's submitted, the results load in the DHTML Window.

The only thing I changed from my first post was to put the DHTML widget call in the brackets after submit. I do not know if it was proper/correct to do that, I tried it and it just happened to work.

This is ALL of the code for BOTH pages, nothing in the dhtml window widget files called from the directory windowfiles was touched.

onchange='popchangeaction(this)'
to this

onChange='submit(popchangeaction(this))'

Below is ALL of the code on both of my pages.

The only other thing I would like to do is hide the widget after a few seconds instead of it staying on the screen.

This is the main page that calls the pop-up and sends the variables


<html>
<head>
<title>Order Processing System </title>
<link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="windowfiles/dhtmlwindow.js">
/***********************************************
* DHTML Window Widget- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script>
function popchangeaction(myForm) {
var w = dhtmlwindow.open("changeaction", "iframe", "op-doad.php", "Change the action", "width=200px,height=200px,resize=1,scrolling=1,left=10px,top=10px");
}
</script>
</head>
<body>
<?php
$edit_time = date('M d Y g:iA', strtotime('now'));
$order_no = '987652';
print "<table>
<tr>
<td>Order No</td>
<td>action_code</td>
</tr>";
?>
<?php
print " <tr>
<td>$order_no</td>
<td>
<FORM target='_iframe-changeaction' action='op-doad.php' method='POST'><input type='hidden' value='$order_no' name='order_no'>
<select type='submit' name='action_code' onchange='popchangeaction(this)'><option value='' selected>blank</option>
<option value='selection1'>selection1</option>
<option value='selection2'>selection2</option>
</select>
</font></td></tr></table></form>';
?>
</body>
</html>


This is the page that is be in the popup and receives the posted variables


<html>
<head>
<title>TITLE</title>
</head>
<body>
<?php
$edit_time = date('M d Y g:iA', strtotime('now'));
$order_no = $_POST['order_no'];
$new_action_code = $_POST['action_code'];

echo'Your order has been submitted for processing.<br />';

echo'<br />';
echo'edit_time';
echo'<br />';
echo $edit_time;
echo'<br />';
echo'order_no';
echo'<br />';
echo $order_no;
echo'<br />';
echo'action_code';
echo'<br />';
echo $new_action_code;
echo'<br />';

echo 'The database has been updated!';
?>

</body>
</html>