Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

document.getElementById with post data in FireFox

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
meirulexite
Asked:
meirulexite
  • 3
  • 2
1 Solution
 
RoonaanCommented:
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
 
meirulexiteAuthor Commented:
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
 
meirulexiteAuthor Commented:
It's working but it doesn't clear the last array displayed.
0
 
RoonaanCommented:
Yes, I made a typo.
selectBox.options.lentgh = 0;
Should be
selectBox.options.length = 0;

-r-
0
 
meirulexiteAuthor Commented:
Thank you!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now