Closed Thread Icon

Topic awaiting preservation: Dynamic forms... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8920" title="Pages that link to Topic awaiting preservation: Dynamic forms... (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Dynamic forms... <span class="small">(Page 1 of 1)</span>\

 
Hub-izer
Bipolar (III) Inmate

From: The little green dot at the center of your monitor
Insane since: Jul 2003

posted posted 10-23-2003 02:01

Righto,

What I'm trying to do is have a select list box with dynamically changing contents. Basically, I want it to have a list of users. Then I want to be able to call a few functions to add and delete users. Is there any way to do this at all? I've tried several ways..nothing seems to work. All I did was the select code..lol.

Thanks...

Kaniz
Bipolar (III) Inmate

From:
Insane since: Jun 2003

posted posted 11-12-2003 20:31

document.form.formname.Select.option[N] = null; will delete an option from the select list
document.form.formname.Select.option[num of options] = 'whatever' will add a new option to the list.

example code, from a project I've done

code:
function PopulateRoom(id)
{
var PopArray = new Array();
if(id == 1) PopArray = Build1;
if(id == 2) PopArray = Build2;

optNum = document.forms.me.RoomType.length;
// delete the options
for(x=0;x<optNum;x++)
document.all.RoomType.options[0] = null;

for(x=0;x<PopArray.length;x++)
{
var Room = PopArray[x].toString().split(":");
document.all.RoomType.options[x] = new Option(Room[1],Room[0]);
}

}



yeah, I know document.all is prob not the best way of doing it, but i know for certian the client is using IE and I'm lazy


DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 11-13-2003 10:43

Here: http://www.faqts.com/knowledge_base/index.phtml/fid/178 you can find loads of examples/questions on javascript and forms.

Some time back I took two pieces of code from here and merged them to create this little thing that allows you to add/delete/sort a selectbox from another selectbox and/or from creating all new values to choose from.
http://www.dmsproject.com/test/misc_js/selectmoving.html
Perhaps it can be of help.
/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

« BackwardsOnwards »

Show Forum Drop Down Menu