www.webdeveloper.com
Results 1 to 11 of 11

Thread: Javascript don't work on IE

  1. #1
    Join Date
    Apr 2009
    Posts
    23

    Javascript don't work on IE

    The previous developer who has been working here used javascript on some forms and they're not functioning properly when opened with IE (any version)

    The link to the form: [LINK]

    On firefox, it doesn't prompt any error and as you can see, it auto selects "Lebanon" as a country and it selects the date with 3 days in between till the return date. These don't work on IE, it just shows blank.

    Here is the javascript used.
    Code:
    $cargroup=$_GET["group"];
    $countryofrental = $_GET["cor"];
    $countryofresidence = $_GET["corofres"];
    $daycoll = date("d") + 2;
    $mthcoll = $_GET["monthcoll"];
    $yearcoll = date("Y");
    $hr = $_GET["hr"];
    
    $dayret = date("d") + 5;
    $mthret = date("m");
    $yearret = date("Y");
    echo '
    <script type="text/javascript">
    function setvalue(){
    var x=document.getElementById("cargroup");
    x.value='.$cargroup.'
    }
    function setvaluectr(){
    var x=document.getElementById("countryofrental");
    x.value='.$countryofrental.'
    }
    function setvaluectrofres(){
    var x=document.getElementById("countryofresidence");
    x.value='.$countryofresidence.'
    }
    function setdaycoll(){
    var x=document.getElementById("daycoll");
    x.value='.$daycoll.'
    }
    function setmthcoll(){
    var x=document.getElementById("monthcoll");
    x.value='.$mthcoll.'
    }
    function setyearcoll(){
    var x=document.getElementById("yearcoll");
    x.value='.$yearcoll.'
    }
    function sethrcoll(){
    var x=document.getElementById("hrcoll");
    x.value='.$hr.'
    }
    
    
    function setdayret(){
    var x=document.getElementById("dayret");
    x.value='.$dayret.'
    }
    function setmthret(){
    var x=document.getElementById("monthret");
    x.value='.$mthret.'
    }
    function setyearret(){
    var x=document.getElementById("yearret");
    x.value='.$yearret.'
    }
    function sethrret(){
    var x=document.getElementById("hrret");
    x.value='.$hr.'
    }
    </script>';
    and here is the call page
    Code:
    <div align="left" style="width:100%" class="componentheading">{formtitle}</div>
    
    <div align="left" style="width:80%;" id="rsform-div">
    <div id="rsform-mandatory">* Mandatory fields</div><br>
    <form name="{formname}" id="{formname}" id="rsform-form" method="post" action="{action}" {enctype}>
    	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="forme">
    	{formfields}
    	</table>
    </form>
    </div>
    <script type="text/javascript">
    setvalue();
    setvaluectr();
    setvaluectrofres();
    setdaycoll();
    setmthcoll();
    setyearcoll();
    sethrcoll();
    
    setdayret();
    setmthret();
    setyearret();
    sethrret();
    </script>
    Any advise? Thanks.
    Last edited by drugoholic; 04-15-2009 at 07:54 AM.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Works in IE8.
    Try moving all those calls to the onload handler.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Apr 2009
    Posts
    23
    Quote Originally Posted by Fang View Post
    Works in IE8.
    Try moving all those calls to the onload handler.
    What onload are you referring to?
    Just for the record, I'm using RSForms with Joomla 1.5
    And the javascript I posted is set inside the form's setting page in Adminpanel of Joomla

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    IE doesn't like changes make to a form until the document has loaded. As you are using MooTools, use the domready to run the form filling functions.

    Why use PHP to fill JavaScript code when the query contains the required data?
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Apr 2009
    Posts
    23
    Quote Originally Posted by Fang View Post
    IE doesn't like changes make to a form until the document has loaded. As you are using MooTools, use the domready to run the form filling functions.

    Why use PHP to fill JavaScript code when the query contains the required data?
    You mean instead of using
    Code:
    <script type="text/javascript">
    setvalue();
    setvaluectr();
    setvaluectrofres();
    setdaycoll();
    setmthcoll();
    setyearcoll();
    sethrcoll();
    
    setdayret();
    setmthret();
    setyearret();
    sethrret();
    </script>
    I should use
    Code:
    <script type="text/javascript">
    window.addEvent('domready', setvalue() {
        alert("The DOM is ready.");
    });
    </script>

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Yes.
    I still don't understand why this is not don't in PHP.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  7. #7
    Join Date
    Apr 2009
    Posts
    23
    Quote Originally Posted by Fang View Post
    Yes.
    I still don't understand why this is not don't in PHP.
    Can you please show me how to add multiple functions in there? or should I put each function in a separate event?

  8. #8
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    window.addEvent('domready', function(){
      myFunction1();
      myFunction2();
      myFunction3();
    });
    At least 98% of internet users' DNA is identical to that of chimpanzees

  9. #9
    Join Date
    Apr 2009
    Posts
    23
    That didn't work

  10. #10
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    In which version of IE does it not work?
    At least 98% of internet users' DNA is identical to that of chimpanzees

  11. #11
    Join Date
    Apr 2009
    Posts
    23
    Quote Originally Posted by Fang View Post
    In which version of IE does it not work?
    IE7 even though it's working like magic on Firefox 3 :/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles