Solved

document.getElementById with post data in FireFox

Posted on 2006-10-23
5
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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'…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

739 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