• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need help with a simple javascript confirmation window

Entity

Lifer
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
 
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
 
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
 
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... 😛

Rob
 
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?');">
 
Back
Top