Results 1 to 8 of 8

Thread: Safari & Firefox problem

  1. #1
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Safari & Firefox problem

    I'm having problems getting this code to work in safari and firefox any idea's
    Code:
    function gotoPrint()
    	{
    		var printNum = Print.value
    			if(printNum=="1")
    				{
    				location.href="purcbody6x6P.html"
    				}
    		
    			if(printNum =="2")
    				{
    				location.href="purcbody.html"
    				}
    
    			if(printNum =="3")
    				{
    				location.href="purcbody.html"
    				}
    	
    			if(printNum =="4")
    				{
    				location.href="purcbody.html"
    				}
    	
    			if(printNum =="5")
    				{
    				location.href="purcbody.html"
    				}
    		
    			if(printNum =="6")
    				{
    				location.href="purcbody.html"
    				}
    			
    			if(printNum =="0")
    				{
    				alert("Please select a print size")
    				return
    				}
    		
    	}

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Where is Print defined in that code?

    You can do that more neatly, too:
    Code:
    function gotoPrint() {
      var printNum = /* whatever */;
      printNum = parseInt(printNum, 10);
      if(!printNum)
        alert("Please select a print size.");
      else if(printNum === 1)
        location.href = "purcbody6x6P.html";
      else if(printNum < 7)
        location.href = "purcbody.html";
    }
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the print is the name of the select tag I'm using this function on. so I would insert print.value where you have whatever?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    But it's not defined as a Javascript variable. You'd need to get a reference:
    Code:
    var printNum = document.getElementsByName("print")[0].value;
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, I tried this but it still doesn't work in firefox or safari only IE
    Last edited by maximo; 06-23-2007 at 02:28 AM. Reason: mistake

  6. #6
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am using the onchange in the select tag instead of using a button, does firefox and safari not support that?

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Oh, my error, you have a capital P:
    Code:
    var printNum = document.getElementsByName("Print")[0].value;
    If it still doesn't work, it would be helpful to see your page.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That was it. I'm sittin here starin at it and did'nt even notice it. Thanks alot I appreciate it

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
  •