|
-
Aug 21st, 2005, 11:54 PM
#1
Thread Starter
Frenzied Member
[Java Script] Confirm Box
Well I am basiclly brand new to Java script, but I don't really plan on getting all that into since I am only looking for a few things. Anyways I read a quick tut got most of the basic syntax down and now I am wondering a few things.
I read up on the confirm box and how it's used. Basicly it returns a True or False value depending on the "Okay" or "Cancel" button clicked.
Well here is what I want to do. I have a form where the user inputs data, and submits it. When the Submit button is hit, I want a Confirm box to appear that asks if the user agree's with the Disclaimer or not. That would be using the "OnClick" event within the Submit type. Then I would simply tell it to call the Java script up from the header.
So I got that down, and the script would just be the confirm, and one more thing. How would I check if the answer was true or false, and then compare and do something with an if stament. Like use an If statment to check if it was true/false. Also, how would I stop the submit button from submitting the form if it was false, and let it continue if it was true.
That's basicly all, know it's kind of simple, but thanks in advanced
Age - 15 ::: Level - Advanced
If you find my post useful please ::Rate It::

-
Aug 21st, 2005, 11:58 PM
#2
Lively Member
Re: [Java Script] Confirm Box
Hi,
like this?
Code:
<html>
<head>
<script type="text/javascript">
function conf()
{
var quit = confirm("Some message here")
// they clicked ok
if(quit) return true;
return false;
}
</script>
</head>
<body>
<form name="myForm" onsubmit="return conf();">
Field 1:<input type="text" name="fld"><br>
Field 2:<input type="text" name="fld2"><br>
Field 3:<input type="text" name="fld3"><br>
<input type="submit" name="sub">
</form>
</body>
</html>
-
Aug 22nd, 2005, 12:10 AM
#3
Thread Starter
Frenzied Member
Re: [Java Script] Confirm Box
Yea okay made it fit thanks 
One more thing, in the Confirm Box text, is there anyway to format the text? Like <br> just show's as plain text, how would I format it, or is it not possible?
Last edited by Inuyasha1782; Aug 22nd, 2005 at 12:23 AM.
Age - 15 ::: Level - Advanced
If you find my post useful please ::Rate It::

-
Aug 22nd, 2005, 12:58 PM
#4
Re: [Java Script] Confirm Box
If you mean line breaks then replace "Some message here" with "Some \n Message \n here"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|