Clear list box

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
coolnfunky_raj
Forum Newbie
Posts: 1
Joined: Tue Apr 17, 2007 10:44 am

Clear list box

Post 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.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

Give the textbox an ID, then use document.GetElementById('boxname[]') to get it. Actually, you should be using getElementById for everything anyways.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

None of this is related to PHP. Moved to Client Side.
Post Reply