Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

RabbitTrail

@RabbitTrail
About
Posts
5
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • focus() not working
    R RabbitTrail

    Thank you. I works fine.

    JavaScript testing beta-testing help

  • focus() not working
    R RabbitTrail

    Thank you for pointing out my mistakes. I modified my code to include your corrections but the focus still does not put the cursor in the blank text or textarea continters. Any other suggestions? I have tried the code in IE, Firefox and Chrome.

    JavaScript testing beta-testing help

  • focus() not working
    R RabbitTrail

    Below is code I have been trying. Everything works except the focus. When the alert box's OK is clicked, focus is not set to the blank text/textarea control that caused the error to happen. According to articles online, this should work but it is not. Any suggestions would be greatly appreciated.

    Trying It Out
    function checkForm()
    {
    var str = ''; //for testing purposes later
    var e = document.getElementById('myForm').elements;

       //Insert for statement here//
    	for(i=0; i <= e; i++){
    		if(e\[i\].value.length <1){
    			alert("The field " + e.\[i\].name + " is blank");
    			var mytext = document.getElementById(e\[i\].name)
    			mytext.focus();
    			return false;
    			
    		}
    	}
    
     }
    

    Your Name:

    Interesting Fact About You:

    something about you


    JavaScript testing beta-testing help

  • Trying to compare cancel from prompt dialog not working
    R RabbitTrail

    Below I have the code I am working with. The if statement in the script is not working. What I want to do is catch the value of the prompt dialog box if the user clicks the cancel buttom and exit the script if that is the case. I have tried: if (color=="null") if (color==="null") if (color=='null') if (color==='null') if (color==null) if (color===null) and none of them work. I can make the script work if I do: if(color!=null) and modify the logical processing but I am trying to make work with the equals comparison. If I comment out the if conditional statement, it works fine. Any help is greatly appreciated. Thank you.

    <!--
    var color = prompt("Enter a color","Enter red, white, or blue.")

    function colorTest(){

        //\*\*\*\*\*\*\*\*\*\* if statement not working properly
    if(color === null){
    	break;
    }
    
    switch(color){
    case "red":
    	alert("You have entered the color ' red '");
    	break;
    case "white":
    	alert("You have entered the color ' white '");
    	break;
    case("blue"):
    	alert("You have entered the color ' blue '");
    	break;
    default:
    	alert("You did not enter a valid color");
    	
    }
    

    }//end function

    //-->

    JavaScript tools help

  • body onunload
    R RabbitTrail

    I have been trying to get the method to work. I have seen and tried quite a few online examples including the example found on W3C (which is below). Even on their site, it doesn't work. I have tried to get the method to work by: Refresh the page, using back and forward buttons, and closing the window. Nothing happens in IE, Firefox or Chrome. I am at a loss as to why this doesn't work.

    <html>
    <head>
    <script>
    function myFunction()
    {
    alert("Thank you for visiting W3Schools!");
    }
    </script>
    </head>

    <body onunload="myFunction()">

    Welcome to my Home Page

    Close this window or press F5 to reload the page.

    </body>
    </html>

    JavaScript html tools tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups