-
Okay im sure this is easy but i cant find out how to do it...
I want to have two select boxes: when you select say computers from select one, select two will display the sub-categories for computers, ie internet, hardware, software etc.
I know how to add options to a select box, but how on earth do you get rid of them???
Any help what so ever so greatfully recieved!..
TIA
-
I made a site just like this for a client. Here's the code you need, it's a little For Loop:
Code:
for (var i = document.yourformname.yourselectname.options.length; i > 0; i--)
document.form1.product.options[i] = null;
That's it! Let me know if you need any more help.
-
Thankyou that is almost working...
Escuse me for my ignorance but i dont often do any client side:
I have this function
function dodelete(){
for (var i = document.all.cats.options.length; i > 0; i--)
document.all.cats.options = null;
}
and this form
<FORM NAME="all">
<SELECT name="cats">
<option value=1>Option One</option>
<option value=1>Option One</option>
</SELECT>
<input type=button onclick="dodelete()">
I get the error "not implimented" on the line with document.all.cats.options = null;
Any ideas what i might be doing wrong?
Cheers
-
Hey madonions,
You might wanna try renaming your form because when IE tries docunemt.all, it is probably not trying ot access the form called all.
Then, you could use:
for (j=0; j < document.formName.selectName.length; j++){
document.formName.selectName.options[j] = null;
}
and that should work.
aDog :cool:
-
I figured out whathappenned and why aepstein's code was wrong:
At first, I did the same as him, but noticed my post was screwed up. He used the VB code to italicize something. Anyway, I just changed mine to [j] so it wouldn't italicize stuff and used the j variable in the for loop.
aDog :cool:
-
haha, thanks, good catch there AriellaDog. Hope you got it working Mad-Onion.
-
Thanks to both of you it is now working!
Thanks Again!!!