LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-24-2005, 08:39 AM   #1
Erhnam
Member
 
Registered: Jan 2005
Posts: 54

Rep: Reputation: 15
[javascript] confirm button on php page


I created a php page with a button and some extra functionality:

PHP Code:
echo "------------<br><br>";
echo 
"<form method='POST' action='function_extract.php'>";
echo 
"Reinstall: </td><td>";

echo 
"<select class='dropdown' name='tarball'>";

exec ("cd /control-panel/ | ls $mm3*-server.tar.gz"$tarlijst);
foreach (
$tarlijst as $inhoud) {
echo 
"<option value='$inhoud'>$inhoud</option>";
}

echo 
"</select>";
echo 
"<br><br><input type='submit' value='Reinstall' OnClick=\"confirmSubmit()\">";
echo 
"</form>"
Now I want to add a confirmation window before proceeding the next page (form).

I included this code

Code:
<script LANGUAGE="JavaScript">
<!--

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
	return true ;
else
	return false ;
}
</script>
But is doesn't seems to work very well.. At least a pop window is displayed but the will always be redirected to the next page. Anyone know exactly how this works?

Last edited by Erhnam; 02-24-2005 at 08:46 AM.
 
Old 02-24-2005, 01:05 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 77
Try changing:
"echo "<form method='POST' action='function_extract.php'>"; "
to:
Code:
echo "<form onsubmit='return confirmSubmit();' method='POST' action='function_extract.php'>";
and "echo "<br><br><input type='submit' value='Reinstall' onClick=\"confirmSubmit()\">";"
to:
Code:
echo "<br><br><input type='submit' value='Reinstall'>";
This works for me with javascript form validation, before sending the form contents back to the php server
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Next - Previous Page Buttons / Search this Thread Button JZL240I-U LQ Suggestions & Feedback 5 11-09-2005 07:40 AM
javascript merge "if confirm" with "submit" rblampain Linux - Software 6 09-18-2005 10:44 AM
can javascript automatically populate login fields and click button for me? opioid Programming 1 02-16-2005 03:58 PM
Logout button on every page bamboo_spider LQ Suggestions & Feedback 7 02-07-2005 01:51 AM
Executing Javascript within a PHP page Linh Programming 3 09-26-2003 05:08 PM


All times are GMT -5. The time now is 08:24 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration