javascript endless select boxes

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Bal
Forum Newbie
Posts: 9
Joined: Tue May 27, 2008 11:45 am

javascript endless select boxes

Post by Bal »

Hi again!

I'm writing a page that uses select boxes. One thing I would like to do when a selection is made in the select boxes is to generate another set of blank boxes, ad infinitum.

I understand this is a fairly simple thing, but am new to javascript (as in starting to learn it as I post this).


EDIT: Altered title and text to reflect purpose of post.
Last edited by Bal on Fri May 30, 2008 8:03 pm, edited 1 time in total.
User avatar
Mini
Forum Newbie
Posts: 23
Joined: Mon Dec 04, 2006 4:39 am
Location: Netherlands

Re: PHP?

Post by Mini »

I think that the thing you want is Javascript. Php is server based.
Well it seems like a simple thing you need, I'm sure you can find it easely on google ;).
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Re: PHP?

Post by Luke »

yea this is a client-side issue. this isn't something php would be capable of unless you actually submitted the page to the server.

Moving to client side...

EDIT: oh and you may want to change the title of your thread to something like "how do you generate a select box with javascript?" or something like that.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: javascript endless select boxes

Post by kaszu »

JS to create select box:

Code: Select all

var select = document.createElement('select');
select.name = 'new_select';
document.getElementsByTagName('body')[0].appendChild(select);
for(var i=0; i<10;i++) {
    var option = document.createElement('option');
    option.value = i;
    option.innerHTML = 'Value ' + i;
    select.appendChild(option);
}
Post Reply