You are here: Re: Array of checkboxes... « HTML « IT news, forums, messages
Re: Array of checkboxes...

Posted by Adrienne on 08/12/05 18:52

Gazing into my crystal ball I observed "Noozer" <dont.spam@me.here>
writing in news:NP%Ke.197751$%K2.23272@pd7tw1no:

> I'm using ASP to generate an array of checkboxes and was wondering what
> was the best way to do it.
>
> I can't use the same name on all the checks, because I only get "on"
> for the checked boxes and nothing with the unchecked boxes.
>
> I can't figure out how to specify an array for the input element name.
>
> When I process the results from the form submission, I need to know the
> index of the checkbox in my database, so I figured that I could use the
> index as part of the input element's name.
>
> Suggestions?
>
>

<% dim fruitarr, fruit
fruitarr = request.form("fruit")

for each fruit in split(fruitarr,", ")
response.write "<br>choice: " & fruit
next

'or you can do it this way

for i = 0 to ubound(split(fruitarr,", "))
response.write "<br>choice" & i & ": " & fruitarr(i)
next

'now that you have values do whatever you need to do with your database

%>
<form method="post" action="<%=request.servervariables("SCRIPT_NAME")%>">
<p>
<input type="checkbox" value="apples" name="fruit">Apples<br>
<input type="checkbox" value="oranges" name="fruit">Oranges<br>
<input type="checkbox" value="bananas" name="fruit">Bananas<br>
<input type="submit" value="Choose">
</p>
</form>

--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация