SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    prompt not apperaring?

    hello!
    Here is the code, what I expect now is the prompt frame to appear, but it is not, and I am asking myself where is the mistake...

    Please, if someone is in the mood, can someone help?

    Many thanks!

    Code:
    <!DOCTYPE html>
    
    <html>
      <body>
      
      
      <p>Please, input 3 numbers 1-9, separated by commas:</p>
      
      
      <input id="angle" type="array">
        
        <button onclick="myFunction()">Search!!!</button>
        <script>
        function myFunction()
        {
        var a=prompt("Please, input a number: ","a");
        var x=document.getElementById("pravokotnik").value;
       for (int i=0; i<5; i+=2){
       if (x[i]==a){alert("Number IS on the list!")} 
     
      
    
       else{alert("Number is NOT on the list!")}
    
        }  
    
       </script>
        </body>
      
      </html>

  2. #2
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    I doubt it would be any good for someone to assist you. Just take a look at the other thread, about the chess board. Did you offer any feedback? Did you learn anything? There's someplace you got stuck?

    The mistake is you taking stabs in the dark and doing things that appear to be way above your current expertise. Best try to properly learn JavaScript, it will be more efficient and more rewarding for everybody.

  3. #3
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mkjs View Post
    hello!
    Here is the code, what I expect now is the prompt frame to appear, but it is not, and I am asking myself where is the mistake...

    Please, if someone is in the mood, can someone help?

    Many thanks!

    HTML Code:
    <!DOCTYPE html>
    
    <html>
      <body>
      
      
      <p>Please, input 3 numbers 1-9, separated by commas:</p>
      
      
      <input id="angle" type="array">
        
        <button onclick="myFunction()">Search!!!</button>
        <script>
        function myFunction()
        {
        var a=prompt("Please, input a number: ","a");
        var x=document.getElementById("angle").value;
       for (int i=0; i<5; i+=2){
       if (x[i]==a){alert("Number IS on the list!")} 
     
      
    
       else{alert("Number is NOT on the list!")}
    
        }  
    
       </script>
        </body>
      
      </html>
    Last edited by Mittineague; Dec 25, 2013 at 12:48.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,053
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    What browser are you using? Does it have an Error Console?
    eg. in Firefox, Tools -> Web Developer -> Error Console
    Getting used to checking error messages will help you see your mistakes and with time you should soon learn how to solve many problems this way.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Is the prompt for debugging purposes? Its use for that purpose has been obsolete since Firefox introduced a full JavaScript debugger into the browser (the last browser to do so).

    If it is for collecting information for the script to actually use on a live web page then that use of prompt has been obsolete since Netscape 4 died.

    There is no legitimate use for prompt in modern JavaScript and it can now be easily turned off in the web browser without affecting the page functioning because Netscape 4 died so long ago that only the occasional debugging use that someone forgot to remove should ever find its way into a live web page.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,053
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    I occassionally still use an alert from time to time for simple testing purposes.
    But even then, console log can be used and is much less annoying to deal with if you mistakenly put an alert inside a loop, or worse a never-ending loop, as it doesn't steal focus from the window.

    @felgall ; this is a homework assignment - which admittedly doesn't say much in terms its educational value - but the OP is stuck needing to figure this out.

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Mittineague View Post
    @felgall ; this is a homework assignment - which admittedly doesn't say much in terms its educational value - but the OP is stuck needing to figure this out.
    It is a pity there are so many "history of JavaScript" classes around pretending to be programming courses.

    Question for the OP: Is JavaScript something that you intend to make use of after the course or is it just something you need to pass as a part of a course in something else where you will never need to touch JavaScript again?

    If you are taking the class to actually learn JavaScript then it will take you three times as long doing this class because you will need to first learn how it used to be done 15 years ago, then forget everything you learnt in the class, then take another class to learn how to program in JavaScript. In this instance the best you can do is drop the class and find one that teaches programming rather than history.

    If it is just something that is a part of a course where your end goal is something else then by all means continue trying to learn how JavaScript was written 15 years ago - the browsers you ought to test in should be Netscape 2 through 4 and IE3 as what the class is teaching is assuming those browsers, don't expect what you write to necessarily work properly in more modern browsers though - there are much better ways available for JavaScript to interact with browsers such as IE4+, Firefox 0.1, Opera 4, etc.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

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