Results 1 to 4 of 4

Thread: [Java Script] Confirm Box

  1. #1

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    [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::


  2. #2
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    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>
    {yak}

  3. #3

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    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::


  4. #4
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: [Java Script] Confirm Box

    If you mean line breaks then replace "Some message here" with "Some \n Message \n here"
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width