![]() |
Adding Options to A Selectbox
I currently have two selectbox, the first for categories and the second for subcategories. When an option from the category selectbox is chosen I would like the subcategory selectbox to be filled with options drawn from an array.
The following code I have works for Chrome and Firefox but not in IE, I would appreciate any help to fix the code or new code which does a similar function. HTML: Code:
<select size="9" id="category" name="category" onclick="return categoryChange();">Code:
function addOption(selectbox,text,value){ |
You probably left out some html , but working
with what you have provided I give you this ... Code:
<html> |
DaveyErwin - <script language=javascript> is long deprecated and obsolete. Use <script type = "text/javascript"> instead. The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning
that you are probably looking at ancient and perhaps unreliable code. supersav144 - use the search feature of this forum for "multi-combo". You will find several good examples. All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit. |
Quote:
possible in the hope that the example will be clear to the original poster concerning their question rather than try to educate them beyond what they have requested and possibly beyond what they are currently prepaired t6o understand. Some are learning from ancient code which may prepare them to at some point grasp more modern concepts. Thank you for pointing this out to readers who are more capable, and thank you for your continuing efforts to improve the quality of this forum. Please, keep up the very good work you do here. Best regards. |
Quote:
|
Quote:
are very well desireved because they are well earned. |
Quote:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
As always, there are many ways to kill a cat! :)
Code:
<html> |
yep, and I guess that is why the op said
Quote:
|
Well, he now has plenty of choice! :)
|
yep, and that's the way it should be imo :)
|
This worked an absolute treat, thank you very much! I do however have one added question which follows along the same lines...
I am passing through the value which is selected for the category, some error checking is then completed and if an error is found it brings you back to the same page where I am displaying back the information entered. The problem is however that I can't seem to set the category select box selected item to whatever was passed through the first time. Here is the code I am using which again works in Chrome/Firefox but not IE. I feel the solution will be something similar to the previous but not entirely sure what... This is the javascript which is run onload of the page Code:
var category; |
You can append the relevant parameters to the url back to the original page and then set the inputs' default settings in the original page according to the paramaters sent back.
Another option is to use session variables to store sent values and then use the session variables to set the default settings of elements in the original page. |
I tried that using 'defaultSelected=.....;' but that didn't seem to work either for some reason.
|
Use a session cookie.
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit. |
| All times are GMT +1. The time now is 05:46 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.