Page 1 of 1

Clear list box

Posted: Tue Apr 17, 2007 11:15 am
by coolnfunky_raj
Hello

I am a newbie to PHP. I was designing a webpage. The page has a list box. I named the listbox list1[] so that I can handle the selected items as an array in PHP. But I have a clear button in the form to clear the contents of the all the text boxes, list boxes and check boxes in the form. I used javascript to clear the contents. When I use "[]" with the listbox name, I am not able to clear the contents of the listbox in javascript. Is there a way by which the list box can be cleared with javascript without affecting the php code much?

Thanks in advance.

Posted: Tue Apr 17, 2007 11:27 am
by Begby
Give the textbox an ID, then use document.GetElementById('boxname[]') to get it. Actually, you should be using getElementById for everything anyways.

Posted: Tue Apr 17, 2007 12:04 pm
by RobertGonzalez
None of this is related to PHP. Moved to Client Side.