Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > display multiple input boxes based on results

Reply
Thread Tools

display multiple input boxes based on results

 
 
Joey
Guest
Posts: n/a
 
      09-29-2004
Say a customer inserts into a sql database field (NUMINSERTS) the number
6.

On the following page, I want to build a table that displays 6 input
boxes, since the customer said they wanted 6 text boxes.

I will then insert the data from the 6 text boxes back into another sql
database table.

For example:
Page 1: Ask client how many items they want to insert. Client types in
6.
Page 2: Table is displayed with input boxes for title of item 1 and
price of item 1. Then title for item2 and price for item 2, and on and
on until 6 are diaplyed.

How do I get the correct number of text boxes to be displayed? AND then,
how do I insert them into another table (ITEMINFO)


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      09-29-2004
Hi Joey,

Try something like this.

<%
''user submitted number already, i.e. 6
iNumberOfTextBoxes = Request.Form("txtNumberOfTextboxesDesired")
''code to make sure there was no
''nonsense input, like a letter, or empty, etc.
%>

<form method="post" action="process.asp">
<% For i = 1 To iNumberOfTextBoxes %>

<input name="txtTitle<%=i%>" type="text">
<input name="txtPrice<%=i%>" type="text">
<% Next %>

<input type="hidden" name="count" value="<%=iNumberOfTextBoxes%>">
<input type="submit">
</form>


process.asp:

<%
iCount = Request.Form("count")
'''open ado connection, oADO
For i = 1 To iCount
sTitle = Request.Form("txtTitle" & i)
sPrice = Request.Form("txtPrice" & i)

'''validate the input here

sSQL = "INSERT INTO someTable (Title,Price) VALUES ('" & sTitle & "'," &
sPrice & ")"
oADO.Execute sSQL,,129
Next
'''close and kill ADO connection
%>

That would be a basic layout of what would happen. You'd generate the form
on the fly with input boxes named:

txtTitle1,txtPrice1
txtTitle2,txtPrice2
txtTitle3,txtPrice3
txtTitle4,txtPrice4
....

Then you'd write the number to a hidden input.

Then when the form is submitted, you'd take the value from the hidden input
and use that to rebuild the input element names.

You'd want to make sure you add validation code all over.

Ray at work




"Joey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Say a customer inserts into a sql database field (NUMINSERTS) the number
> 6.
>
> On the following page, I want to build a table that displays 6 input
> boxes, since the customer said they wanted 6 text boxes.
>
> I will then insert the data from the 6 text boxes back into another sql
> database table.
>
> For example:
> Page 1: Ask client how many items they want to insert. Client types in
> 6.
> Page 2: Table is displayed with input boxes for title of item 1 and
> price of item 1. Then title for item2 and price for item 2, and on and
> on until 6 are diaplyed.
>
> How do I get the correct number of text boxes to be displayed? AND then,
> how do I insert them into another table (ITEMINFO)
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
 
Joey
Guest
Posts: n/a
 
      09-30-2004
Ray, thanks for your help. That's what I needed!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ajax call to fetch multiple results from multiple queries and showing them 1 by 1 as the results comes. Biranchi Narayan Panda ASP .Net 0 02-21-2010 03:46 PM
Display query results based on selected fields Mike ASP .Net 3 08-20-2009 11:31 PM
Readline and conditional tab results based on input Marc Heiler Ruby 7 07-10-2009 12:22 PM
Space between input boxes and selection boxes is not the same in Internet Explorer Stefan Mueller HTML 5 06-16-2009 02:06 PM
Different user input boxes are automatically populated based on a value of the dropdown box. reneeccwest Javascript 2 07-11-2003 11:35 PM



Advertisments