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

javascript working incorrectly in mozilla with select element

Hi, I've searched the forum for this problem but haven't found anything relevant.
I've got a javascript code which dynamically creates list-boxes in a form. It
works perfectly fine in IE, but in Firefox 2 I change the selected value in
a list-box but nothing gets submitted via POST.
The dynamic list-box creation code looks like this:
[HTML]
<form name="form0" method=POST action="/dynamic/AppDirector/Global/GlobalParameters" onkeypress="return webDefaultFormKeyHandler(this,event,IDN_Conversion _Page_Set_Handler)">
<table border=0>
<tr><td class="varName">
<b>Open New Entry When Source Port Different</b>
</td>
<td class="varValue" id="varValue1">
<input type="hidden" name="mibId_0" value="187">
<script language="JavaScript1.2" type="text/javascript">
var187_0Object = new SelectBox("var187_0","varValue1");
var187_0Object.add("enable","enable");
var187_0Object.add("disable","disable");
var187_0Object.setValue("disable");
</script></td></tr>[/HTML]

SelectBox is defined in another javascript file, and the code goes like this:
Expand|Select|Wrap|Line Numbers
  1. function SelectBoxSetValue(value) {
  2.   options = this.sel.options;
  3.   for (i=0;i<options.length;i++) {
  4.     if (options[i].value == value) {
  5.       this.sel.selectedIndex = i;
  6.     }
  7.   }
  8. }
  9.  
  10. function SelectBoxAdd(text,value)
  11. {
  12.   ops = this.sel.options;
  13.   for (i=0;i<ops.length;i++) {
  14.     if (ops[i].text == text) {
  15.       return;
  16.     }
  17.   }  
  18.   o = document.createElement("OPTION");
  19.   o.text = text;
  20.   o.value = value;
  21.   addoption(this.sel,o);  
  22. }
  23.  
  24. function SelectBox(name,parentId) {
  25.   this.sel  = document.createElement("SELECT");
  26.   this.sel.name = name;
  27.   this.sel.id   = name;
  28.   if (parentId != null) {
  29.     this.par   = document.getElementById(parentId);   
  30.   } else {
  31.     this.par   = document;
  32.   }
  33.   this.add      = SelectBoxAdd;
  34.   this.remove   = SelectBoxRemove;
  35.   this.setValue = SelectBoxSetValue;
  36.   this.par.appendChild(this.sel);
  37. }
  38.  
Can anyone give some pointers as to why this wouldn't work in Firefox?
Thanks in advance
Sep 6 '07 #1
3 1889
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Perhaps line 31 should be
Expand|Select|Wrap|Line Numbers
  1. this.par = document.body;
Sep 7 '07 #2
Welcome to TSDN!

Perhaps line 31 should be
Expand|Select|Wrap|Line Numbers
  1. this.par = document.body;
Thanks!
I managed to solve the problem, fortunately. I had the<form> element as a direct son of <table>, and firefox didn't like it that much :))
Sep 9 '07 #3
acoder
16,027 Expert Mod 8TB
Glad you got it working and thanks for posting your solution.

Post again should you need help on a JS problem.
Sep 9 '07 #4

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

Similar topics

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: 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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.