Web Analytics Made Easy -
StatCounter Dialogue boxes help - CodingForum

Announcement

Collapse
No announcement yet.

Dialogue boxes help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dialogue boxes help

    I am sorry if that was a bad subject. I have a few questions about prompt boxes, alerts, and confirmations. I browsed the web for them, but I couldn't find the answer so I came here.
    Here are the questoins:

    1. Is it possible to create your own buttons to click on the alerts or prompts, or any other dialogue box. So on confirmation boxes the choices could be "Yes, No, or cancel"

    2. Is it possible to do those in forms, or in a way without dialogue boxes
    http://www.stophon4.com

  • #2
    It wasn't a bad thread title so don't worry about it.

    In answer to your first question, check out this thread, that should explain what you want to know.

    For your second question, in forms you can create your own buttons, so you can use them to display what every you want and perform various finctions onclick with JavaScript. So the short answer would be yes.

    Code:
    <form action="#">
    
    <input type="button" value="Yes" onclick="alert('Yes');">
    <input type="button" value="No" onclick="alert('No');">
    <input type="button" value="Cancel" onclick="alert('Cancel');">
    
    </form>
    AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
    BFG GeForce 6800 Ultra OC 256Mb
    3 * Kingston 256Mb PC3200 DDR400
    Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

    Comment


    • #3
      Yes, you will find there a nice VBscript/javascript solution, yet don't forget that I think VBscript means IE only....

      The perfect cross-browser solution remains, I think, to build your own graphical buttons using Photoshop, Corel or another good graph tool.
      KOR
      Offshore programming
      -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

      Comment


      • #4
        aright, I am knew to JavaScript, How do you import the buttons?
        and can you choose their function? and on more:
        Can you bookmark JS?

        sorry, My JavaScript book stinks
        http://www.stophon4.com

        Comment


        • #5
          Originally posted by stophon4
          How do you import the buttons?
          To "import" the buttons just copy and paste the HTML code into your page. Simple as that.

          Originally posted by stophon4
          can you choose their function?
          Of course you can choose the JavaScript functions that are run onclick, otherwise what would the point of them be?

          Originally posted by stophon4
          Can you bookmark JS?
          I have no idea what you mean here.
          AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
          BFG GeForce 6800 Ultra OC 256Mb
          3 * Kingston 256Mb PC3200 DDR400
          Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

          Comment


          • #6
            well, in html you can hyperlink to some where on the page. I was wondering if you could do that with JavaScript to.

            But during all this I forgot the question that I wanted to know more than anything.
            here is an example of some code and what I want to do with it:
            var age=prompt("What is your age?", "some random age")
            if(age=='5')
            {
            alert("your a kid")
            }

            I want the alert to pop up if they enter a age 5-9, How do I do that?

            (I know that JS was stupid, it was just a example)
            http://www.stophon4.com

            Comment


            • #7
              Originally posted by stophon4
              well, in html you can hyperlink to some where on the page
              That's what anchor tags are for though, there is no need to use JavaScript to perform such a task, especially as approximately 13% of the web-browsing public don't have JavaScript enabled.

              Here's a fairly heavy duty script that should do what you want for the age thing:

              Code:
              var age=prompt("What is your age?", "some random age");
              
              while(!age || age.replace(/\D/g,"")==""){age=prompt("What is your age?", "some random age");}
              
              age=parseInt(age.replace(/\D/g,""));
              
              if(age>=5 && age<=9){alert("You're a kid.");}
              The while loop makes sure that the user enters something that has at least one number in it. (The !age makes sure that they didn't just press cancel and the .replace removes non-numbers and then makes sure that there is something left.)

              The age=parseInt(age.replace(/\D/g,"")); removes any non-numbers and converts the string into a number for use later on.

              The if() should be fairly self explanatory.
              AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
              BFG GeForce 6800 Ultra OC 256Mb
              3 * Kingston 256Mb PC3200 DDR400
              Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

              Comment


              • #8
                thanks
                http://www.stophon4.com

                Comment


                • #9
                  Happy to help.
                  AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
                  BFG GeForce 6800 Ultra OC 256Mb
                  3 * Kingston 256Mb PC3200 DDR400
                  Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

                  Comment


                  • #10
                    aright, here is the actual code I am using and it isn't working:
                    var score=prompt("What is you highscore for icy-tower?", "somerandomnumber")
                    while(!score || score.replace(/\D/g,"")==""){score=prompt("What is your age?", "some random age")
                    score=parseInt(score.replace(/\D/g,""));
                    if(score>=0 && <=4999)
                    http://www.stophon4.com

                    Comment


                    • #11
                      Always check your code:

                      Code:
                      var score=prompt("What is you highscore for icy-tower?", "somerandomnumber")
                      while(!score || score.replace(/\D/g,"")==""){score=prompt("What is your age?", "some random age")
                      score=parseInt(score.replace(/\D/g,""));
                      if(score>=0 && <=4999)
                      You've missed off a closing } for the while loop, you've missed off the word "score" before the <=4999 and of course, you're not running anything with the if statement, (you also didn't change the text in the second prompt). The code should look like this:

                      Code:
                      var score=prompt("What is your highscore for icy-tower?", "somerandomnumber");
                      
                      while(!score || score.replace(/\D/g,"")==""){score=prompt("What is your highscore for icy-tower?", "somerandomnumber");}
                      
                      score=parseInt(score.replace(/\D/g,""));
                      
                      if(score<=4999){alert();}
                      I have removed the score>=0 since the replace(/\D/g,"") would remove the minus sign from any numbers that are negative.
                      AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
                      BFG GeForce 6800 Ultra OC 256Mb
                      3 * Kingston 256Mb PC3200 DDR400
                      Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

                      Comment


                      • #12
                        What part of it isn't working? Like what IS happening?

                        Firstly I can see that you're missing a curly brace.

                        Your code should read:
                        Code:
                        var score=prompt("What is you highscore for icy-tower?", "somerandomnumber");
                        while(!score || score.replace(/\D/g,"")=="") {
                         score=prompt("What is your age?", "some random age");
                        }
                        score=parseInt(score.replace(/\D/g,""));
                        if(score>=0 && <=4999) {
                         alert(...);
                        }
                        At least I think that's what it should read, syntactically...

                        If you can clear up what doesn't work, then maybe someone can be of more help.

                        EDIT: Whoa looks like I was beat to the post! We've said the same thing... though lavalamp had some more pointers

                        Sadiq.

                        Comment


                        • #13
                          how do you loop JavaScript? just wondering, thanks
                          http://www.stophon4.com

                          Comment


                          • #14
                            Loop Javascript?

                            Well there are 3 different loops in Javascript:
                            1. for loop
                            2. while loop
                            3. do while loop

                            Check out this link for more information:


                            There is also a "foreach" type of loop in Javascript as well. It's the for loop, but it takes different "parameters". But I forget how it looks like. I think I used it once, but I can't remember how it goes.

                            Hope that helps,
                            Sadiq.

                            Comment


                            • #15
                              I mean for alerts, so I could make an alert appear two or three times.
                              http://www.stophon4.com

                              Comment

                              Working...
                              X