Solved

document.getElementById with post data in FireFox

Posted on 2006-10-23
5
216 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
ID: 17787783
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
ID: 17787892
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
ID: 17787991
It's working but it doesn't clear the last array displayed.
0
 
LVL 49

Expert Comment

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

-r-
0
 

Author Comment

by:meirulexite
ID: 17788030
Thank you!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTTPS jquery doesn't work 9 63
Java Script Error encountered while loading a page, IBM Lotus Notes 6 23
Converting dates in JavaScript 2 36
Button and js nou working 3 8
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

822 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