Solved

document.getElementById with post data in FireFox

Posted on 2006-10-23
5
221 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Suggested Courses

622 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