SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    charleston
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    FF - IE7 problem with form fieldset

    Hi,

    I have a multilingual website with three languages. I use a form with checkboxes to switch between languages. There is no "submit" button, the language switches when the user clicks on one of the three checkboxes. This works great in FF but does not work in IE7. This is the first time I am trying to do this so I am not sure where the problem is.

    <div class="language">
    <form action="">
    <fieldset>
    <ul>
    <li class="active"><a class="english" href="<?php echo switchLanguage('en') ?>" title="English" ><input type="checkbox" checked="checked"/><span>English</span></a></li>
    <li><a class="china" href="<?php echo switchLanguage('ch') ?>" title="Chinese"><input type="checkbox" /><span>Chinese</span></a></li>
    <li><a class="spanish" href="<?php echo switchLanguage('es') ?>" title="Spanish"><input type="checkbox" /><span>Espaņol</span></a></li>
    </ul>
    </fieldset>
    </form>
    </div>
    this is the php script used for language switching. not sure if this is important for this issue or not, but i thought i include it:

    <?php
    function switchLanguage($language_code){
    $uri = explode('?',$_SERVER['REQUEST_URI']);
    $uri = array_slice(explode('/',$uri[0]),1);
    if($uri[0]=='de' || $uri[0]=='en')
    array_shift($uri);
    array_unshift($uri,$language_code);
    return '/'.implode('/',$uri);
    }
    ?>
    I appreciate any help!
    thank you

  2. #2
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,287
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    Since the HTML doesn't (cannot) change languages, it's something in the PHP.

    Also, beware of using anchors to change language. Some people use nasty browsers or browser extentions whose job is to click on every link on a page (so that if the user were to actually click on that link themselves, they don't need to wait for DNS request)... meaning the last language selectable might always appear for those people.

    You can use HTTP headers to turn this "prefetching" off.

    Also, what does your HTML really look like? (there isn't any PHP actually showing is there??)

  3. #3
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    charleston
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I included the actual html that I am using to switch languages. This also includes the php in the anchor tag. For example, here is one line:
    "><a class="english" href="<?php echo switchLanguage('en') ?>" title="English" ><input type="checkbox" checked="checked"/><span>English</span></a>
    I think the php works fine because I can actually switch the languages in FireFox by just clicking in the checkbox and then the languge switches. In IE when I click in the checkbox, nothing happens BUT in IE I can click on the flag or on the word (which is also in the anchor tag) and then the script switches the language. So, really, my questions is, why does IE not switch when I check the checkbox?

  4. #4
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,782
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    It might be hard to do with a pure HTML solution but if you want the JS route you can do
    Code:
    <!doctype html><html>
    <head>
    <script type="text/javascript">
    <!--
    function checkb1() { 
       alert("You clicked on checkbox 1"); 
    }
    function checkb2() { 
       alert("You clicked on checkbox 2"); 
    }
    function checkb3() { 
       alert("You clicked on checkbox 3"); 
    }
    //-->
    </script>
    </head>
    <body>
    <form>
    <input type="checkbox" onClick="checkb1()">A<br>
    <input type="checkbox" onClick="checkb2()">B<br>
    <input type="checkbox" onClick="checkb3()">C
    </form>
    </body>
    </html>
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  5. #5
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    charleston
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am actually thinking about getting rid of the checkboxes, and doing it all with css. So have the entire language button be one link with a custom displayed checkmark. That may work better and be easier for cross browser stuff

  6. #6
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,782
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    I'd do radios and that way you can't have multiple items selected AND it is possible to have them moved onclick without the use of JS, pure HTML.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  7. #7
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,287
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    I've never seen proper HTML, as seen by a browser, having any non-html code in it. PHP belongs in the dirty back end on the server side where it does its dirty work. It should never appear in the source.


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
  •