Results 1 to 8 of 8

Thread: Works in firefox/safari/opera but not in IE

  1. #1
    Join Date
    Dec 2008

    Works in firefox/safari/opera but not in IE


    im building a website where you click an image on a map and it ticks the checkbox in a form associated with that image. There are 11 images and 11 checkboxes. Im using a onclick="checked(1);" through to "onclick="checked(11);" on each image link which refers to this JS script:

    function checked(n) {
    	   box = eval("document.getElementById('deal'+n)");
    	   if (box.checked == false) {
    		  box.checked = true;
    	   } else {
    		  box.checked = false;
    each checkbox has the id="deal1" through to id="deal11"

    Currently it works a treat in everything except IE. when you click it checks the box and when you click again it unchecks it. IE however does nothing.

    Any help would be much appreciated
    Last edited by bobmcjob; 12-08-2008 at 10:22 PM.

  2. #2
    Join Date
    Dec 2005


    Try this ...
    PHP Code:
    function checked(n) {
    box document.getElementById('deal'+n);
           if (
    box.checked == false) {
    box.checked true;
           } else {
    box.checked false;

  3. #3
    Join Date
    Dec 2008
    cheers, i gave it a whirl, still doesnt work in IE

    im only new to javascript is there a common rule or something im missing as to why firefox 3/2 and every other browser interprets it correctly but IE doesn't?

  4. #4
    Join Date
    Dec 2005


    Quote Originally Posted by bobmcjob View Post
    cheers, i gave it a whirl, still doesnt work in IE

    im only new to javascript is there a common rule or something im missing as to why firefox 3/2 and every other browser interprets it correctly but IE doesn't?
    Can you post the full script?
    It should work, but you might have an error elsewhere.

  5. #5
    Join Date
    Dec 2008
    Firstly here is the image map which calls the checked(); function when the image is clicked. I have other functions that show hidden info divs when the mouse hovers over the image.

    HTML Code:
     <map name="Map" id="Map">
                        <area shape="poly" coords="421,374,431,390,444,403,435,449,418,453,407,445,408,415,432,411,411,379" href="#deal1" alt="" onmouseover="showtext(1);showbox();" onmouseout="hidebox();" onclick="checked(1)" />
                        <area shape="poly" coords="307,428,295,427,324,353,343,409,339,422,326,428" href="#deal2" alt="" onmouseover="showtext(2);showbox();" onmouseout="hidebox();" onclick="checked(2)" />
                        <area shape="poly" coords="236,410,217,366,207,397,205,450,233,450" href="#deal3" alt="" onmouseover="showtext(3);showbox();" onmouseout="hidebox();" onclick="checked(3)" />
                        <area shape="poly" coords="315,328,372,328,374,310,347,293,315,307" href="#deal4" alt="" onmouseover="showtext(4);showbox();" onmouseout="hidebox();" onclick="checked(4)"/>
                        <area shape="poly" coords="290,513,285,441,308,434,331,464,336,514" href="#deal5" alt="" onmouseover="showtext(5);showbox();" onmouseout="hidebox();" onclick="checked(5)"/>
                        <area shape="poly" coords="333,347,373,368,385,337,356,335" href="#deal6" alt="" onmouseover="showtext(6);showbox();" onmouseout="hidebox();" onclick="checked(6)"/>
                        <area shape="poly" coords="393,345,448,345,437,333,450,315,435,305,422,309,391,329" href="#deal7" alt="" onmouseover="showtext(7);showbox();" onmouseout="hidebox();" onclick="checked(7)" />
                        <area shape="poly" coords="281,60,339,57,321,38,301,24" href="#deal8" alt="" onmouseover="showtext(8);showbox();" onmouseout="hidebox();" onclick="checked(8)"/>
                        <area shape="poly" coords="227,127,310,124,296,67,266,71,234,106" href="#deal9" alt="" onmouseover="showtext(9);showbox();" onmouseout="hidebox();" onclick="checked(9)"/>
                        <area shape="poly" coords="64,118,171,119,172,80,66,80" href="#deal10" alt="" onmouseover="showtext(10);showbox();" onmouseout="hidebox();" onclick="checked(10)"/>
                        <area shape="poly" coords="181,61,127,73,88,62,112,42,153,44" href="#deal11" alt="" onmouseover="showtext(11);showbox();" onmouseout="hidebox();" onclick="checked(11)"/>
    					<area shape="poly" coords="57,65,36,54,15,74,18,100,40,122,56,118" href="#deal12" alt="" onmouseover="showtext(12);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="292,137,358,110,403,141,344,150" href="#deal13" alt="" onmouseover="showtext(13);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="71,186,131,185,118,151,100,125,75,160" href="#deal14" alt="" onmouseover="showtext(14);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="90,258,96,237,83,205,118,202,115,234,111,256" href="#deal15" alt="" onmouseover="showtext(15);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="295,288,282,265,292,231,323,233,335,262,323,278" href="#deal16" alt="" onmouseover="showtext(16);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="351,251,352,213,355,189,368,173,377,197,383,220,366,250" href="#deal17" alt="" onmouseover="showtext(17);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="388,291,376,260,382,242,430,249,431,291" href="#deal18" alt="" onmouseover="showtext(18);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="246,326,306,327,318,356,296,372,249,361" href="#deal19" alt="" onmouseover="showtext(19);showbox();" onmouseout="hidebox();" />
                        <area shape="poly" coords="240,485,247,458,285,492,272,524,246,516" href="#deal20" alt="" onmouseover="showtext(20);showbox();" onmouseout="hidebox();" />
    Below is the form where each check box has the id of deal1 through to deal11

    HTML Code:
    <form action="entry.php"  method="post" >
                                 <fieldset id="offers">
                                 	<fieldset class="checkbox">
                                        <input type="hidden" name="deal1" value="" />
                                        <input type="checkbox" name="deal1" id="deal1" />
                                        <label for="deal1">25% off Madagascan Explorer</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal2" value=""/>
                                        <input type="checkbox" name="deal2" id="deal2" />
                                        <label for="deal2">25% off Okavango Experience</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal3" value=""/>
                                        <input type="checkbox" name="deal3" id="deal3" />
                                        <label for="deal3">25% off Namibia Lodge Safari</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal4" value=""/>
                                        <input type="checkbox" name="deal4" id="deal4" />
                                        <label for="deal4">25% off Mt Kilimanjaro Marangu Route</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal5" value=""/>
                                        <input type="checkbox" name="deal5" id="deal5" />
                                        <label for="deal5">50% off 4 Day Kruger Adventure</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal6" value=""/>
                                        <input type="checkbox" name="deal6" id="deal6" />
                                        <label for="deal6">50% off Zanzibar Beach Break</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal7" value=""/>
                                        <input type="checkbox" name="deal7" id="deal7" />
                                        <label for="deal7">50% off Sunrise Balloon Ride</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal8" value=""/>
                                        <input type="checkbox" name="deal8" id="deal8" />
                                        <label for="deal8">Free Dahab Beach Break</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal9" value=""/>
                                        <input type="checkbox" name="deal9" id="deal9" />
                                        <label for="deal9">Free Alexandria City Break</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal10" value=""/>
                                        <input type="checkbox" name="deal10" id="deal10" />
                                        <label for="deal10">50% off Active Morocco</label>
                                    <fieldset class="checkbox">
                                        <input type="hidden" name="deal11" value=""/>
                                        <input type="checkbox" name="deal11" id="deal11" />
                                        <label for="deal11">50% off Essaouira Escape</label>
                        <h3 class="sub-header">And enter to win a trip to Kenya and Tanzania - tell us why you want to win in 25 words or less</h3>
                        	<fieldset id="entry">
                                    <textarea name="comp_entry" title="Competition Entry" id="comp_entry" class="[val,8]" rows="0" cols="0" onkeypress="textCounter(this,this.form.counter,255);" ></textarea>
                        <!-- End Entry -->
                        		<fieldset id="submit-btn">
                                    <input class="continue" type="image" name="submit" src="css/images/btn_continue.gif" value="continue" onclick="entryCheck();" />
    the javascript that is called from the image map is below

    function checked(n) {
           box = document.getElementById('deal'+n);
           if (box.checked == false) {
              box.checked = true;
           } else {
              box.checked = false;
    It has me baffeled. Thanks for your help

  6. #6
    Join Date
    Mar 2007
    Quote Originally Posted by bobmcjob View Post
    HTML Code:
     <fieldset class="checkbox">
      <input type="hidden" name="deal1" value="" />
      <input type="checkbox" name="deal1" id="deal1" />
    document.getElementById in I.E. doesn't distinguish between name and ID, so you cant use the same identifier for name and ID on different elements.
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  7. #7
    Join Date
    Dec 2005
    How about a link to where the image for the map
    and the missing functions (textcounter(), entryCheck(), etc.)
    and class="[val,8]" are located.

    I'm getting too many errors to find out why the "checked(n)" function doesn't work.

  8. #8
    Join Date
    Dec 2008
    Cheers Logic Ali, i changed the name on the hidden input fields and thats worked!! Thank you everyone for your help

Thread Information

Users Browsing this Thread

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

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13331 seconds
  • Memory Usage 2,966KB
  • Queries Executed 13 (?)
More Information
Template Usage (36):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (3)bbcode_html
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (8)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates