473,776 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

tjc0ol
26 New Member
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="feedbac k.php" method="post">
<fieldset>
<legend class="ledgende r">Contact US</legend>
<table border="0" cellpadding="8" cellspacing="8" summary="feedba ck 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>Telepho ne No.:</td><td ><input name="telno" type="text" size="37" /></td></tr>
<tr><td>Comme nt Type:</td>
<td >
<select name="attn" onchange="disab le_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="disab led" /></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 1760
Gulzor
27 New Member
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 New Member
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="javas cript:disable_e nable();">
[/HTML]
or

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


best regards,

maminx
Jul 24 '08 #3
maminx
77 New Member
and of course, what is the error that show in the browser??
Jul 24 '08 #4
tjc0ol
26 New Member
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 New Member
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
4893
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 and can't figure out how to make it work in, for instance, Firefox. Right now the code I am using is as follows: newOpt=document.createElement('OPTION'); newOpt.id='optKeyword'; newOpt.label='Keyword';...
8
3674
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
1
2467
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 guy's Javascript "combo box" - http://sandy.mcarthur.org/javascript/select/select.html. It allows my users (when I get some!) to select from a list of preexisting options and also to add a new one by clicking on "add new". Essentially it's a select...
0
9464
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10122
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6722
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5368
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
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.