473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

HELP: Javascript does not work in Firefox

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 8907
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,460 Expert Mod 2GB
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
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
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,460 Expert Mod 2GB
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
Thanks KUB.
Aug 23 '06 #7
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
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...
12
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...
7
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>...
5
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> .......
8
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...
6
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...
4
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
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 ...
0
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...
16
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.