Need help with a simple javascript confirmation window

Entity

Lifer
Oct 11, 1999
10,090
0
0
I've changed my plans slightly on how I need to setup this script, so I have a quick question.

A user will fill out a form, and then click "OK." At that point, a confirmation script - a little popup window - will pop up and ask if they are sure they want to modify the data/delete the data. If they answer yes, the form is submitted; if they answer no, the popup window just closes. Is there a way to do this without passing all the information using POST through to the confirmation box?

Rob
 

CrazyDe1

Diamond Member
Dec 18, 2001
3,089
0
0
You have to pass all the information if you want to submit it...if you dont' like post use GET>=P
or you could also use session variables..but that sux
 

Entity

Lifer
Oct 11, 1999
10,090
0
0
Ok, then, here's my problem.

I have mainpage.php, and when someone clicks "edit," it takes them to "selectprof.php."

In this, I run a little MySQL query to give a drop-down select box of all the professors in the database:

echo "<select name=\"person_id\">";
echo "<option></option>";

$query = "SELECT person_id, firstname, lastname from tb_person";
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());

while (list($person_id, $firstname, $lastname) = mysql_fetch_row($result))

{
echo "<option value=$person_id>$firstname $lastname</option>";
}

echo "</select>";

How can I make it so that when someone clicks "edit" (submitting the form) the $person_id variable is passed to the parent window? I can get it to pass through to the popup just fine, just using action=whatever.php and method=post, but I can't figure out how to make whatever.php open in the main window.

The only thing I can think of (please let me know if this is the only way to do it) is have the form call a separate PHP file which contains JavaScript that, in turn, validates the data and then runs a function to close the popup and open the new page in the parent window. That, to me, seems too complex...

Any other ideas?

Right now I have this in the head of selectprof.php:

<script language="JavaScript" type="text/javascript">
<!--
function Yes(person_id) {
var person_id = "http://webapps.biostat.washington.edu/cvOnline/prof/editprof.php?<? echo $person_id; ?>"
window.opener.location = address;
window.close();
}

function No() {

window.close();
}
//-->
</script>

But it won't work since the $person_id variable isn't initialized until after someone clicks "edit."

Rob
 

Entity

Lifer
Oct 11, 1999
10,090
0
0
Anyone? I'm going to need this confirmation script, in the future, to pass a whole bunch of variables, so hopefully I can figure this out... :p

Rob
 

Beau

Lifer
Jun 25, 2001
17,730
0
76
www.beauscott.com
Originally posted by: Entity
I've changed my plans slightly on how I need to setup this script, so I have a quick question.

A user will fill out a form, and then click "OK." At that point, a confirmation script - a little popup window - will pop up and ask if they are sure they want to modify the data/delete the data. If they answer yes, the form is submitted; if they answer no, the popup window just closes. Is there a way to do this without passing all the information using POST through to the confirmation box?

Rob

in the <form> tag add this:

<form onSubmit="return confirm('Are you sure you want to modify/delete the data?');">