|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
#1
|
|||
|
|||
|
Hello,
Some one has asked this before but I didn't get the answer I seek from the replies. When someone clicks the submit button on a form on my website, how do I make a pop-up window (java or web browser) appear confirming that their request has been received? Please consider that I am very html challenged. Thank you. |
|
#2
|
||||
|
||||
|
are you talking about something like this (not valid HTML, I know):
Code:
<html>
<head>
<script type="text/javascript">
function confSubmit(form) {
if (confirm("Are you sure you want to submit the form?")) {
form.submit();
}
else {
alert("You decided to not submit the form!");
}
}
</script>
</head>
<body>
<form action="somefile.php" method="POST">
<!--Put form elements here-->
<input type="button" onClick="confSubmit(this.form);" value="Submit Form">
</form>
</body>
</html>
Hope this helps.
__________________
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989 The Testing Site | Atomic Yeti |
|
#3
|
||||
|
||||
|
Here is another example in which the form has a submit button rather than a normal command button
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function executeOnSubmit()
{
var status = checkField();
if(status == false)
{
alert('Please enter some data in the text field');
return false;
}
var res = confirm("Do you really wish to submit the form contents?");
if(res)
return true;
else
return false;
}
function checkField()
{
//Please note that I haven't done any detailed form validation in this case.
var elemValue = document.getElementById("name").value;
if(elemValue == "")
return false;
else
return true;
}
</script>
</head>
<body>
<form action="test.php" method="post" onsubmit="return executeOnSubmit();">
<label>Name</label><input type="text" name="name" size="20" id="name" />
<br>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
|
|
#4
|
|||
|
|||
|
This can be done as easy as this: I did it with a anchor rather than button:
<a href="delete.php" onclick="return confirm('Are you sure you want to delete this item?');">delete</a> Cheers, Nima Dezhkam |
|
#5
|
||||
|
||||
|
Quote:
The code you've provided does not submit a form as the click on the link will open a confirm box and will be redirected to the file or sit idle based on the confirm button click. Suppose think that the file that contains the link you've provided an HTML form a submit/normal button and the user wish to submit the form. How could one can achieve this with your code? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|