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
- <script language="JavaScript">
- <!--
- function ButtonClick()
- {
- if (document.survey.clickcount.value > 0)
- {
- // drag drop result
- var urlString = '';
- // check button result
- urlString = '';
- for (idx=0; idx < 17; idx++)
- {
- document.getElementById('v' + (idx+1)).value = document.getElementById('Img' + (idx+1)).myclick;
- }
- }
- else
- {
- if (document.survey.q23a.value == '' && document.survey.q23b.value == '' && document.survey.q23c.value == '')
- {alert("Sorry, you must select or type at least one ");
- return false}
- }
- }
- function CheckClick(ctrl)
- {
- if (document.getElementById(ctrl.id).myclick == '2')
- {
- //New function start 18-Aug-2006
- var txtcount = 0;
- if (document.survey.q23a.value !="")
- txtcount += 1;
- if (document.survey.q23b.value !="")
- txtcount += 1;
- if (document.survey.q23c.value !="")
- txtcount += 1;
- if ((parseInt(document.survey.clickcount.value) + txtcount) >= 3)
- { alert("Sorry, you can only select or type three maximum ");
- return false;}
- //New function end 18-Aug-2006
- //the following two lines are used to calculate number of clicks.
- if (document.survey.clickcount.value >= 3){
- //document.survey.clickcount.value=parseInt(document.survey.clickcount.value) + 1;
- alert("Sorry, you can only select or type three maximum ");}
- else{
- document.getElementById(ctrl.id).myclick = '1';
- document.getElementById(ctrl.id).src='images\\' + ctrl.id + '_on.gif';
- document.survey.clickcount.value=parseInt(document.survey.clickcount.value) + 1;}
- }
- else if (document.getElementById(ctrl.id).myclick == '1')
- {
- document.survey.clickcount.value=parseInt(document.survey.clickcount.value) - 1;
- document.getElementById(ctrl.id).myclick = '2';
- document.getElementById(ctrl.id).src='images\\' + ctrl.id + '_off.gif';
- }
- }
- function NewFun(txtv)
- {
- var txtcount = 0;
- if (document.survey.q23a.value !="")
- txtcount += 1;
- if (document.survey.q23b.value !="")
- txtcount += 1;
- if (document.survey.q23c.value !="")
- txtcount += 1;
- if ((parseInt(document.survey.clickcount.value) + txtcount) > 3)
- { alert("Sorry, you can only select or type three maximum ");
- document.getElementById(txtv.id).value = "";
- return false;}
- }
- //-->
- </script>
- The elements on the page are (sorry, it is a lot):
- <form name="survey" action="survey_23.asp" method="get">
- <input type="hidden" name="clickcount" value=0>
- <table width="700" height="423" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td width="700" height="371" valign="top" background="images/23_radio_bg.jpg">
- <div id="DivCheckBox" style="Z-INDEX: 105; LEFT: 0px; WIDTH: 700px; POSITION: relative; TOP: 0px; HEIGHT: 72px">
- <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <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>
- <td><img src="images/Img3_off.gif" width="76" height="37" border="0" id="Img3" onClick="CheckClick(this)" myclick="2"></td>
- <td> </td>
- <td> </td>
- <td><img src="images/Img7_off.gif" width="68" height="34" border="0" align="right" id="Img7" onClick="CheckClick(this)" myclick="2"></td>
- <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>
- </tr>
- <tr>
- <td><img src="images/Img11_off.gif" width="79" height="43" border="0" id="Img11" onClick="CheckClick(this)" myclick="2"></td>
- <td> </td>
- <td><img src="images/Img2_off.gif" width="77" height="35" border="0" id="Img2" onClick="CheckClick(this)" myclick="2"></td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td><img src="images/Img1_off.gif" width="75" height="35" vspace="10" border="0" id="Img1" onClick="CheckClick(this)" myclick="2"></td>
- <td> </td>
- <td> </td>
- <td valign="top"><img src="images/Img13_off.gif" width="81" height="37" border="0" id="Img13" onClick="CheckClick(this)" myclick="2"></td>
- <td> </td>
- </tr>
- <tr>
- <td><img src="images/Img15_off.gif" width="71" height="34" border="0" id="Img15" onClick="CheckClick(this)" myclick="2"></td>
- <td> </td>
- <td><img src="images/Img9_off.gif" width="68" height="34" border="0" id="Img9" onClick="CheckClick(this)" myclick="2"></td>
- <td> </td>
- <td> </td>
- <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>
- </tr>
- <tr>
- <td colspan="2"><img src="images/Img14_off.gif" width="123" height="37" border="0" id="Img14" onClick="CheckClick(this)" myclick="2"></td>
- <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>
- <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>
- </tr>
- <tr>
- <td> </td>
- <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>
- <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>
- <td> </td>
- </tr>
- </table>
- </div></td>
- </tr>
- <tr>
- <td height="29" valign="middle" bgcolor="#3399CC"><table width="100%" height="16" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="322"><img src="images/text_top_radio.gif" width="322" height="16"></td>
- <td width="120"><input name="q23a" type="text" class="input01" id="q23a" maxlength="99" value="" onKeyUp="return NewFun(this)"></td>
- <td width="3"><img src="images/spacer.gif" width="2" height="1" border="0" value="" onKeyUp="return NewFun(this)"></td>
- <td width="120"><input name="q23b" type="text" class="input01" id="q23b" maxlength="99" value="" onKeyUp="return NewFun(this)"></td>
- <td width="3"><img src="images/spacer.gif" width="2" height="1" border="0"></td>
- <td width="120"><input name="q23c" type="text" class="input01" id="q23c" maxlength="99" value="" onKeyUp="return NewFun(this)"></td>
- <td width="12"><img src="images/spacer.gif" width="12" height="1" border="0"></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <input type="hidden" name="RespID" value="<%=request("RespID")%>">
- <input type="hidden" name="tribe" value="<%=request("tribe")%>">
- <input type="hidden" name="v1">
- <input type="hidden" name="v2">
- <input type="hidden" name="v3">
- <input type="hidden" name="v4">
- <input type="hidden" name="v5">
- <input type="hidden" name="v6">
- <input type="hidden" name="v7">
- <input type="hidden" name="v8">
- <input type="hidden" name="v9">
- <input type="hidden" name="v10">
- <input type="hidden" name="v11">
- <input type="hidden" name="v12">
- <input type="hidden" name="v13">
- <input type="hidden" name="v14">
- <input type="hidden" name="v15">
- <input type="hidden" name="v16">
- <input type="hidden" name="v17">
- <td height="23"><table width="700" height="23" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <% if request("bp")="" then %>
- <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>
- <% else %>
- <td width="56"><img src="pbar/spacer.gif" name="backbut" width="56" height="23" border="0" id="backbut"></td>
- <% end if %>
- <td width="588"><img src="pbar/pbar09.gif" width="588" height="23"></td>
- <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>
- </tr>
- </table></td>
- </tr>
- </table>
- </form>
Thanks in advance.
Stewart