473,386 Members | 1,712 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,386 software developers and data experts.

Adding javascript to select element won't work on Firefox browser.

tjc0ol
26
Hi all,
I made contact page which allows visitors to input their name, email address, phone number, comments and select a comment type by using <select> element in html with javascript. Among the option of it are: General Support, Technical Support, Sales in billing, Request RA no. and Others. If they select Others there will be a pop-up textbox for others(so they can specify a comment type) and the textbox is placed on a DIV. I placed CSS on it in which the Visibility is set to "hidden" and put an ID to the DIV which is equivalent to <div id="oh">.
The problem is that the script won't work on FireFox but it will work on IE7, IE6, Safari & Opera browsers.

How to make it work on FireFox browsers?

Here's my html and javascript code below:

[HTML]
<form name="cont" action="feedback.php" method="post">
<fieldset>
<legend class="ledgender">Contact US</legend>
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form" align="center">
<tr><td>Name:</td><td ><input type="text" name="name" size="37" /></td></tr>
<tr><td>Email address:</td><td ><input type="text" name="email" size="37" /></td></tr>
<tr><td>Telephone No.:</td><td ><input name="telno" type="text" size="37" /></td></tr>
<tr><td>Comment Type:</td>
<td >
<select name="attn" onchange="disable_enable()">
<option value=" General Support ">General Support</option>
<option value=" Technical Support ">Technical Support</option>
<option value=" Sales In Billing ">Sales In Billing</option>
<option value=" Request Return Authorization (RA) No. ">Request Return Authorization (RA) No.</option>
<option value=" Others ">Others</option> </select></td></tr>
<tr><td class="txt-centre" colspan="2">
<div id="oh"><strong>Others: </strong><input name="anothers" type="text" size="37" disabled="disabled" /></div></td></tr>
<tr>
<td colspan="2">
Comments<br />
<textarea rows="15" cols="55" name="comments"></textarea>
</td></tr>
<tr><td align="center" colspan="2">
<input type="submit" value="Send Feedback" />
</td>
</tr>
</table>
</fieldset>
</form>
[/HTML]


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3. function disable_enable(){
  4. if (document.cont.attn.options[document.cont.attn.selectedIndex].text=="Others"){
  5. document.cont.anothers.disabled=false;
  6. oh.style.visibility='visible';
  7. }
  8. else
  9.    {                
  10.  document.cont.anothers.disabled=true;
  11.  document.cont.anothers.value='';
  12.  oh.style.visibility='hidden';
  13.    }
  14. }
  15. //-->
  16. </script>
Thanks in advance. -tj
Jul 24 '08 #1
5 1729
Gulzor
27
try to initialize js var "oh" first :

Expand|Select|Wrap|Line Numbers
  1. var oh = document.getElementById("oh");
then

Expand|Select|Wrap|Line Numbers
  1. oh.style.visibility = "hidden"; // or "visible"
Jul 24 '08 #2
maminx
77
To make sure, try to make the
alert("enter");

right after the function, to make sure whether the function being called or not.
If the problem is that you can't enter the function disable_enable() in Firefox, change your HTML select command like this below :

[HTML] <select name="attn" onchange="javascript:disable_enable();">
[/HTML]
or

[HTML] <select name="attn" onchange="return disable_enable();">[/HTML]


best regards,

maminx
Jul 24 '08 #3
maminx
77
and of course, what is the error that show in the browser??
Jul 24 '08 #4
tjc0ol
26
try to initialize js var "oh" first :

Expand|Select|Wrap|Line Numbers
  1. var oh = document.getElementById("oh");
then

Expand|Select|Wrap|Line Numbers
  1. oh.style.visibility = "hidden"; // or "visible"
Thanks a lot, I tried this one and it work. -tj
Jul 26 '08 #5
tjc0ol
26
and of course, what is the error that show in the browser??
In Firefox when you clicked on the others in <select> there's no pop-up will show.

By the way I tried your code above and it won't work. Anyways thanks for the infos. -tj
Jul 26 '08 #6

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

Similar topics

10
by: David | last post by:
Can anyone give me a quick code snippet (that is standards-based) for adding OPTION tags to a SELECT dynamically. I have no problem doing it in IE but I am kind of new to the whole standards world...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
1
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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,...

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.