473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP: Javascript does not work in Firefox

4 New Member
Hi all, I'm new to this forum and I am hoping that there is someone here who can help me.

I have an ASP page that has javascript that works perfectly in IE, but not in Firefox. Can anybody tell me how to get it to work in FF. I can insert a browser identifier and redirect if the script has to change for FF only.

Basically, when a vistor goes to the page they are asked to click on images to chose the top 3 that they like - the images changes colour (another image) when they click on it and changes back if they click again. All of the validation (that is in the script as well) works, but the clicking on the images to change does not work. The code is below:
Expand|Select|Wrap|Line Numbers
  1.  
  2.         <script language="JavaScript">
  3. <!--
  4. function ButtonClick()
  5.             {
  6.                 if (document.survey.clickcount.value > 0)
  7.                 {
  8.                     // drag drop result
  9.                     var urlString = '';
  10.                     // check button result
  11.                     urlString = '';
  12.                     for (idx=0; idx < 17; idx++)
  13.                     {
  14.                         document.getElementById('v' + (idx+1)).value = document.getElementById('Img' + (idx+1)).myclick;
  15.                     }
  16.                 }
  17.                 else 
  18.                 {
  19.                     if (document.survey.q23a.value == '' && document.survey.q23b.value == '' && document.survey.q23c.value == '')
  20.                     {alert("Sorry, you must select or type at least one ");
  21.                     return false}
  22.                 }                
  23.             }
  24.  
  25.             function CheckClick(ctrl)
  26.             {
  27.  
  28.                 if (document.getElementById(ctrl.id).myclick == '2')
  29.                 {
  30.  
  31.             //New function start 18-Aug-2006            
  32.             var txtcount = 0;
  33.             if (document.survey.q23a.value !="")
  34.                 txtcount += 1;
  35.             if (document.survey.q23b.value !="")
  36.                 txtcount += 1;
  37.             if (document.survey.q23c.value !="")
  38.                 txtcount += 1;
  39.             if ((parseInt(document.survey.clickcount.value) + txtcount) >= 3)
  40.                 { alert("Sorry, you can only select or type three maximum ");
  41.                     return false;}
  42.             //New function end 18-Aug-2006
  43.                     //the following two lines are used to calculate number of clicks.
  44.                     if (document.survey.clickcount.value >= 3){
  45.                     //document.survey.clickcount.value=parseInt(document.survey.clickcount.value) + 1;
  46.                     alert("Sorry, you can only select or type three maximum ");}
  47.                     else{
  48.                     document.getElementById(ctrl.id).myclick = '1';
  49.                     document.getElementById(ctrl.id).src='images\\' + ctrl.id + '_on.gif';
  50.                     document.survey.clickcount.value=parseInt(document.survey.clickcount.value) + 1;}
  51.                 }
  52.                 else if (document.getElementById(ctrl.id).myclick == '1')
  53.                 {
  54.                     document.survey.clickcount.value=parseInt(document.survey.clickcount.value) - 1;
  55.                     document.getElementById(ctrl.id).myclick = '2';
  56.                     document.getElementById(ctrl.id).src='images\\' + ctrl.id + '_off.gif';
  57.                 }
  58.             }
  59.  
  60.             function NewFun(txtv)
  61.             {
  62.             var txtcount = 0;
  63.             if (document.survey.q23a.value !="")
  64.                 txtcount += 1;
  65.             if (document.survey.q23b.value !="")
  66.                 txtcount += 1;
  67.             if (document.survey.q23c.value !="")
  68.                 txtcount += 1;
  69.             if ((parseInt(document.survey.clickcount.value) + txtcount) > 3)
  70.                 { alert("Sorry, you can only select or type three maximum ");
  71.                     document.getElementById(txtv.id).value = "";
  72.                     return false;}
  73.             }
  74. //-->
  75. </script>
  76.  
  77. The elements on the page are (sorry, it is a lot):
  78.  
  79. <form name="survey" action="survey_23.asp" method="get">
  80. <input type="hidden" name="clickcount" value=0>
  81. <table width="700" height="423" border="0" align="center" cellpadding="0" cellspacing="0">
  82. <tr>
  83. <td width="700" height="371" valign="top" background="images/23_radio_bg.jpg">
  84.     <div id="DivCheckBox" style="Z-INDEX: 105; LEFT: 0px; WIDTH: 700px; POSITION: relative; TOP: 0px; HEIGHT: 72px">
  85. <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
  86. <tr>
  87. <td><div align="left"><img src="images/Img6_off.gif" width="69" height="35" hspace="5" border="0" align="center" id="Img6" onClick="CheckClick(this)" myclick="2"></div></td>
  88. <td><img src="images/Img3_off.gif" width="76" height="37" border="0" id="Img3" onClick="CheckClick(this)" myclick="2"></td>
  89. <td>&nbsp;</td>
  90. <td>&nbsp;</td>
  91. <td><img src="images/Img7_off.gif" width="68" height="34" border="0" align="right" id="Img7" onClick="CheckClick(this)" myclick="2"></td>
  92. <td><img src="images/Img10_off.gif" width="120" height="38" hspace="13" border="0" align="right" id="Img10" onClick="CheckClick(this)" myclick="2"></td>
  93. </tr>
  94. <tr>
  95. <td><img src="images/Img11_off.gif" width="79" height="43" border="0" id="Img11" onClick="CheckClick(this)" myclick="2"></td>
  96. <td>&nbsp;</td>
  97. <td><img src="images/Img2_off.gif" width="77" height="35" border="0" id="Img2" onClick="CheckClick(this)" myclick="2"></td>
  98. <td>&nbsp;</td>
  99. <td>&nbsp;</td>
  100. <td>&nbsp;</td>
  101. </tr>
  102. <tr>
  103. <td>&nbsp;</td>
  104. <td><img src="images/Img1_off.gif" width="75" height="35" vspace="10" border="0" id="Img1" onClick="CheckClick(this)" myclick="2"></td>
  105. <td>&nbsp;</td>
  106. <td>&nbsp;</td>
  107. <td valign="top"><img src="images/Img13_off.gif" width="81" height="37" border="0" id="Img13" onClick="CheckClick(this)" myclick="2"></td>
  108. <td>&nbsp;</td>
  109. </tr>
  110. <tr>
  111. <td><img src="images/Img15_off.gif" width="71" height="34" border="0" id="Img15" onClick="CheckClick(this)" myclick="2"></td>
  112. <td>&nbsp;</td>
  113. <td><img src="images/Img9_off.gif" width="68" height="34" border="0" id="Img9" onClick="CheckClick(this)" myclick="2"></td>
  114. <td>&nbsp;</td>
  115. <td>&nbsp;</td>
  116. <td><div align="right"><img src="images/Img8_off.gif" width="75" height="37" border="0" align="right" id="Img8" onClick="CheckClick(this)" myclick="2"><img src="images/Img5_off.gif" width="92" height="41" vspace="7" border="0" align="right" id="Img5" onClick="CheckClick(this)" myclick="2"></div></td>
  117. </tr>
  118. <tr>
  119. <td colspan="2"><img src="images/Img14_off.gif" width="123" height="37" border="0" id="Img14" onClick="CheckClick(this)" myclick="2"></td>
  120. <td colspan="3" valign="top"><img src="images/Img12_off.gif" width="103" height="34" hspace="23" vspace="5" border="0" align="left" id="Img12" onClick="CheckClick(this)" myclick="2"></td>
  121. <td align="right"><div align="right"><img src="images/Img17_off.gif" width="161" height="51" vspace="5" id="Img17" onClick="CheckClick(this)" myclick="2"></div></td>
  122. </tr>
  123. <tr>
  124. <td>&nbsp;</td>
  125. <td valign="bottom"><img src="images/Img16_off.gif" width="66" height="35" vspace="3" border="0" id="Img16" onClick="CheckClick(this)" myclick="2"></td>
  126. <td colspan="3" valign="top"><img src="images/Img4_off.gif" width="122" height="40" border="0" id="Img4" onClick="CheckClick(this)" myclick="2"></td>
  127. <td>&nbsp;</td>
  128. </tr>
  129. </table>                
  130. </div></td>
  131. </tr>
  132. <tr>
  133. <td height="29" valign="middle" bgcolor="#3399CC"><table width="100%" height="16" border="0" cellpadding="0" cellspacing="0">
  134. <tr>
  135. <td width="322"><img src="images/text_top_radio.gif" width="322" height="16"></td>
  136. <td width="120"><input name="q23a" type="text" class="input01" id="q23a" maxlength="99" value="" onKeyUp="return NewFun(this)"></td>
  137. <td width="3"><img src="images/spacer.gif" width="2" height="1" border="0" value="" onKeyUp="return NewFun(this)"></td>
  138. <td width="120"><input name="q23b" type="text" class="input01" id="q23b" maxlength="99" value="" onKeyUp="return NewFun(this)"></td>
  139. <td width="3"><img src="images/spacer.gif" width="2" height="1" border="0"></td>
  140. <td width="120"><input name="q23c" type="text" class="input01" id="q23c" maxlength="99" value="" onKeyUp="return NewFun(this)"></td>
  141. <td width="12"><img src="images/spacer.gif" width="12" height="1" border="0"></td>
  142. </tr>
  143. </table></td>
  144. </tr>
  145. <tr>
  146. <input type="hidden" name="RespID" value="<%=request("RespID")%>">
  147. <input type="hidden" name="tribe" value="<%=request("tribe")%>">
  148. <input type="hidden" name="v1">
  149. <input type="hidden" name="v2">
  150. <input type="hidden" name="v3">
  151. <input type="hidden" name="v4">
  152. <input type="hidden" name="v5">
  153. <input type="hidden" name="v6">
  154. <input type="hidden" name="v7">
  155. <input type="hidden" name="v8">
  156. <input type="hidden" name="v9">
  157. <input type="hidden" name="v10">
  158. <input type="hidden" name="v11">
  159. <input type="hidden" name="v12">
  160. <input type="hidden" name="v13">
  161. <input type="hidden" name="v14">
  162. <input type="hidden" name="v15">
  163. <input type="hidden" name="v16">
  164. <input type="hidden" name="v17">
  165. <td height="23"><table width="700" height="23" border="0" cellpadding="0" cellspacing="0">
  166. <tr>
  167. <% if request("bp")="" then %>
  168. <td width="56"><a href="survey_21.asp?bp=1&RespID=<%=request("RespID")%>&tribe=<%=request("tribe")%>" onMouseOver="MM_swapImage('backbut','','pbar/back02.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="pbar/back01.gif" alt="BACK ONE QUESTION" name="backbut" width="56" height="23" border="0" id="backbut"></a></td>
  169. <% else %>
  170. <td width="56"><img src="pbar/spacer.gif" name="backbut" width="56" height="23" border="0" id="backbut"></td>
  171. <% end if %>
  172. <td width="588"><img src="pbar/pbar09.gif" width="588" height="23"></td>
  173. <td width="56"><input type="image" name="submit" value="NEXT" src="pbar/next01.gif" alt="NEXT QUESTION" width="56" height="23" border="0" id="submit" onMouseOver="MM_swapImage('submit','','pbar/next02.gif',1)" onMouseOut="MM_swapImgRestore()" onClick="return ButtonClick()"></td>
  174. </tr>
  175. </table></td>
  176. </tr>
  177. </table>
  178. </form>
  179.  
I would be grateful to anybody who can help me on this, as I have got out of my depth with this problem.

Thanks in advance.

Stewart
Aug 21 '06 #1
7 8915
Falcon4
3 New Member
I didn't take all the time to see all that code (in theory it should be a very simple few-line script with a short array and a toggle if/else block), but as you know your own code best - plus being a bit of a JS n00b myself, I just offer one hint: Check the Tools menu for the JavaScript Console. It will tell you everything causing errors in your script. If you visit pages with ads on them, you'd probably do good to Clear them first, though... lots of sloppy coders out there =)
Aug 21 '06 #2
Niheel
2,456 Recognized Expert Moderator Top Contributor
Code tags help other members read the code a bit better. They makie it easier to for readers (potential helpers) sort out the code from the explanation part.

I went ahead and made the changes for you.

Here are some instructions on using code tags:
http://www.thescripts.com/forum/misc.php?do=bbcode#code
Aug 21 '06 #3
Papelotte
4 New Member
I didn't take all the time to see all that code (in theory it should be a very simple few-line script with a short array and a toggle if/else block), but as you know your own code best - plus being a bit of a JS n00b myself, I just offer one hint: Check the Tools menu for the JavaScript Console. It will tell you everything causing errors in your script. If you visit pages with ads on them, you'd probably do good to Clear them first, though... lots of sloppy coders out there =)
Thanks for the advice and I do apologise for the large amount of code I have pasted. I did say that this was the first time I had done this and I really did not know of any other way - I do now.

Anyway, I have checked the Javascript Console and it shows no errors. It simply does not work in FF. To check if my console was working OK, I inserted an error and it showed. When I corrected it, no errors. I cannot understand, as according to all the JS sites on the web, it should work in FF.

Thanks for your advice anyway.
Aug 22 '06 #4
Papelotte
4 New Member
Thank you KUB635 (administrator) . I feel suitably put down now. I did say that this was the first time I had ever done this and I was expecting a little help rather than a condescending critique of my posting.

Rest assured that, in the future, I will follow your advice in posting. However, maybe you could show me what you mean this time.
Aug 22 '06 #5
Niheel
2,456 Recognized Expert Moderator Top Contributor
Papelotte,

Sorry for the way it came out in writing, i see my error now. It was just suppose to be an instruction for people who would end up posting replies to your question.

Here are the instructions to posting code:
http://www.thescripts.com/forum/misc.php?do=bbcode#code

If you have any questions, please feel free to PM me.

Thanks,
KUB
Aug 22 '06 #6
Papelotte
4 New Member
Thanks KUB.
Aug 23 '06 #7
schizoman
1 New Member
I think that I'm experiencing the same problem. I have the following image and form element:

Expand|Select|Wrap|Line Numbers
  1. <img src="../../images/layout/noimage.jpg" id="pic16" name="pic16" style="height: 75px;">
  2. <input type="file" name="imfiles[16]" id="imfiles[16]" class="txtinput" size="10" onChange="imUpdate(16);">
  3.  
The javascript function changes the source of the image to whatever filename is selected in the input element:

Expand|Select|Wrap|Line Numbers
  1. function imUpdate(_which)
  2. {
  3.     _imID = "pic"+_which;
  4.     _elID="imfiles["+_which+"]";
  5.     _src=document.getElementById(_elID).value;
  6.     document.getElementById(_imID).src=_src;
  7. }
  8.  
  9.  
This works in IE, but not FF. I'm hoping this is just a matter of scripting, and not some sort of security problem. I use similar code on the back ends of several websites.
Nov 3 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3009
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at all, or works sporadically. I'm talking about things like Hotmail, Yahoo Address Book, buttons on various sites, etc.. I'm a computer person, but...
12
1918
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can (in)validate my Javascript code. First, I'll describe the purpose of the Javascript code. I often have a need to post a URL to something at my own...
7
1806
by: f1crazed | last post by:
Ok, The following html works wonderful in IE. It does not work in FireFox. Can someone please tell me the work around for FireFox to get this to work. HTML DOCUMENT: <html> <head> <title>CSS Z-order Test</title> <script language=Javascript>
5
31207
by: Derek Erb | last post by:
I am banging my head against the wall with this one. The following code snippets work perfectly fine in MSIE6. But produce an error in Firefox and do not work at all. BROWSER.HTM <HTML> .... <div class="Abb"> <h2 id="ABTit">BROWSER</h2> </div>
8
3366
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some problems. IE crashes when one refreshes the page or leave the page. This happens only after calling the Java method more than once. It does not crash if...
6
14889
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function keypress() {
4
2315
by: lmarceglia | last post by:
Hi, I have this website that doesn't work in Firefox 1.5: www.pianetaluca.com The HTML source is: <TITLE>PianetaLuca</TITLE> </HEAD>
5
2515
by: Olly | last post by:
Hello Everyone! Could someone please have a look at my JS Form I posted below....Something wrong there, but I don't understand what's exactly. Many thanks. Olly =============================== <script language="JavaScript">
0
5532
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
16
2305
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript on the same page work correctly. It appears to be isolated to 1-2 machines in a particular network. I cannot verify whether these machines have...
0
7396
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5323
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.