Solved

document.getElementById with post data in FireFox

Posted on 2006-10-23
5
214 Views
Last Modified: 2008-02-26
I have this code:

it works and changes the select field.
but the data doesn't go into the form past (only in firefox, in IE it works great)



      function swap(array)
                        {
                              var opts = eval(array);
                              var str='<SELECT name="pizzabase" class="select1" onChange="changebase(value);"><option value=0>Select base</option>'
                              for (i=0; i<=opts.length-1; i++)
                              {str+="<option value="+opts[i] +">"+opts[i]+"</option>"}
                              str+="</select>"
                              
                              
                              document.getElementById('cell').innerHTML=str
                        }
0
Comment
Question by:meirulexite
  • 3
  • 2
5 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
Comment Utility
Does the select exist from starters?

Then you might want to use:

function swap(array) {
  var opts = eval(array);
  var selectBox = document.forms[0].pizzabase;
  selectBox.options.lentgh = 0;
  for(i = 0; i < opts.length; i++) {
    selectBox.options[i] = new Option(opts[i],opts[i]);
  }
}

-r-

0
 

Author Comment

by:meirulexite
Comment Utility
I didn't explain my self:

1. this select box changes according to another select box (that trigers the swap)
2. the options in the select box very with every change of the main select box.
I have a var:

var Pizza1 =  new Array(option1, option2);
var Pizza2 =  new Array(option1, option2);
......

I've replaced the code and it doesn't change the options.
0
 

Author Comment

by:meirulexite
Comment Utility
It's working but it doesn't clear the last array displayed.
0
 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
Yes, I made a typo.
selectBox.options.lentgh = 0;
Should be
selectBox.options.length = 0;

-r-
0
 

Author Comment

by:meirulexite
Comment Utility
Thank you!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now