SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast janoble's Avatar
    Join Date
    Sep 1999
    Location
    Littleton, Colorado
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with checkbox & history.go in IE

    I am having trouble getting IE to recognize that the state of a checkbox has changed. All the script needs to do is recognize the checkbox has changed and reload the page without changing the checkbox status. The script also has to toggle the variable sav between 0 if checked to 1 if unchecked. To reload the page I used history.go(0) in a timeout so that the page will reload every x milliseconds to capture other dynamic events. To illustrate what Iím doing and the problem Iím having, I created the test script below. This script works fine and does what I want in Netscape 7.2 and Firefox 1.5, but does not change the value of sav or recognize the checkbox change in IE 6.0 or 5.5.

    Thanks for any help!

    Script:
    Code:
    <html>
    <head>
      <title>Test</title>
    </head>
    <body>
    <form name="myform">
      <input type="checkbox" name="cb" CHECKED onClick="history.go(0);">Check for Sav=0
    </form>
    <script language="JavaScript">
    <!--
      var sav;
      if (document.myform.cb.checked) {
         sav = 0;
         document.write("<br>Checked");
      } else {
         sav =1;
         document.write("<br>unChecked");
      }
      document.write("<br>sav="+sav);
      timerID = setTimeout("history.go(0)", 5000);
    //-->
    </script>
    </body>
    </html>
    Last edited by janoble; Jul 10, 2006 at 07:30.
    --
    -je-

  2. #2
    SitePoint Enthusiast janoble's Avatar
    Join Date
    Sep 1999
    Location
    Littleton, Colorado
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with checkbox & history.go in IE

    I have tried various tests and it appears that once the page is loaded IE will not re-run the javascript with history.go(0). Does anyone know how I can change the minimalist code below to reload the page and set the value of sav in IE?

    Here's the latest version of my script:
    Code:
    <html>
    <head>
      <title>Test 4</title>
    </head>
    <body>
    <form name="mf">
      <input type="checkbox" name="cb" CHECKED onClick="history.go(0)">Check (Sav=0)
    </form>
    <script language="javascript" type="text/javascript">
    <!--
      if (!sav) {
        var sav = 0;
      }
      if (document.mf.cb.checked) {
        sav = 0;
      } else {
        sav = 1;
      }
      document.write("<br>sav=", sav);
      timerID = setTimeout("history.go(0)", 10000);
    //-->
    </script>
    </body>
    </html>
    I can't believe that something so simple has had me stumped for three days now.

    Frustrated!
    --
    -je-

  3. #3
    SitePoint Enthusiast janoble's Avatar
    Join Date
    Sep 1999
    Location
    Littleton, Colorado
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Solution

    Since no one had any suggestions, I thought I would share the solution I came up with.

    I created a php redirect page which redirects to one of two html pages which have the checkbox and the variable set appropriately. I gave up on javascript re-evaluating and reloading the single html page in IE.
    --
    -je-


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
  •