Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script worked locally but not on server

    I have a button on my page that calls this function. On my machine everything worked fine, but on the server after pushing the button, it does not pull up the prompt. It simply writes to the document with null.

    Code:
    function average(){
    	var num1 = prompt("Please enter a number","0");
    	var num2 = prompt("Please enter another number","0");
    	var num3 = prompt("Please enter a third number","0");
    	var avg = (parseInt(num1) + parseInt(num2) + parseInt(num3)) / 3;			
    	document.write("You entered: ",num1,", ",num2,", and ", num3,"<br>");
    	document.write("Average: ",avg,"<br>");
    }

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    this likely has to do with the way your button is calling the function, please paste that markup if your problem is not resolved by adjusting the security settings for your page.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #3
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <input type="button" onclick="average()" value="Average Fun">
    By the security settings, do you mean the permissions? I set them to 755.

  • #4
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    no, i mean the settings on your browser that determine the zone permissions you have, it's possible your page is in the "restricted" zone and thus the scripts aren't bein allowed to run properly.

    change the commas (,) in your document.write statements to the plus sign (+)
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender


  •  

    Posting Permissions

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