Sending checkbox to another page (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


wizard_oz -> Sending checkbox to another page (1/22/2006 9:04:22)

Hi, I would like to send a some checkboxs to another page
I have some data and it works fine but what should I write in the request.form (the other page)
while not rs2.EOF
%>
	<TR>
		<TD><INPUT type="checkbox" id=" " name=<%=rs2("Software")%>></TD>
		<TD><%=rs2("Software")%></TD>
	</TR>
<%
	rs2.MoveNext
	wend


thanks, Elen




BeTheBall -> RE: Sending checkbox to another page (1/22/2006 11:05:35)

Checkboxes are a little different than other form fields in that nothing is sent unless the box is checked. You must assign a value attribute to the checkbox and whatever that value is, is what will go to the next page, database, etc.

Here are a couple of examples.

Suppose you are selling t-shirts and you have several checkboxes for the color, a box named red, a box named blue and a box named green. The value of each checkbox is True. If the user checks each box, then you have three form field values of true that are sent to the next step.

The other example is almost the same except instead of the boxes being named, red, blue and green, they are all named color and instead of the values being True, the value of one is red, another blue and the last green. If again the user checks all three boxes, what is sent to the next page is a comma-delimited string that looks like this:

red,blue,green

I suspect this may not directly answer your question, but may give you some insight into how checkboxes behave and help you do what you need. If not, feel free to clarify your needs.




wizard_oz -> RE: Sending checkbox to another page (1/22/2006 16:02:39)

I see what you mean.But I can't give the fields a certien name because I don't know how many fields I have....
I was thinking of your second example, but in your example, how do I read the variables in my other page? Do your have any other suggestion for me how do send some variable to another page?





Spooky -> RE: Sending checkbox to another page (1/22/2006 16:30:16)

The way you are sending them (from your example) is almost correct.
You need a name and a value
eg :
<INPUT type="checkbox" name="software" value="<%=rs2("Software")%>">

Ideally, the rs would be a numeric output representing the software.
eg :
1 = Windows
2 = Linux
3 = Apple

So - if the user selects all, the output of request.form("software") would be "1,2,3"

Now you have a comma delimited array which can be split() or used in the processing page







wizard_oz -> RE: Sending checkbox to another page (1/23/2006 6:51:33)

Thanks,what I get at the other page is "on,on,on,on......" ,But I do I know which one of the "on" belong to Windows? Linux? (in your example)




Spooky -> RE: Sending checkbox to another page (1/23/2006 13:49:18)

My assumption is - <%=rs2("Software")%> would be a different value for any saved items.
What is the value saved in the database and how are they stored?




wizard_oz -> RE: Sending checkbox to another page (1/23/2006 16:36:33)

The Values are 2 columns 1 is the ID and the second is the software name like Windows,Office,linux etc.




wizard_oz -> RE: Sending checkbox to another page (1/24/2006 12:52:25)

Can Someone help me please.
Can Someone send me an example of code that use "checkbox", I need to transfer the checkboxes that I marked to another page
I don't have any idea how to do it......





Spooky -> RE: Sending checkbox to another page (1/24/2006 14:42:39)

Your code should be something like this : (assuming ID is the name of the auto column
		<TD><INPUT type="checkbox" id=" " name=software value=<%=rs2("ID")%>></TD>
		<TD><%=rs2("Software")%></TD>


Its probably passing "on" if you dont have a valid code for the checkboxes.
That can be checked by viewing the source in your browser for that page




wizard_oz -> RE: Sending checkbox to another page (1/25/2006 1:20:44)

Thanks, But how should I create the second page (the page I am recieving the data)?
something like: rs=request.form(.........???




wizard_oz -> RE: Sending checkbox to another page (1/26/2006 7:10:51)

SomeOne......




Spooky -> RE: Sending checkbox to another page (1/26/2006 13:26:03)

We need to confirm what is happening on that second page

What happens when you do :

<%=response.write("software")%>




wizard_oz -> RE: Sending checkbox to another page (1/29/2006 2:40:50)

The result is the word "software". My problem is , how do I recive the data from the first page? for example, when I am sending a textbox, I give it a name (something like Firstname) and at the second page I am writing Name=request.form("Firstname"), So what Shild I write at the second page for the Checkbox?




wizard_oz -> RE: Sending checkbox to another page (2/8/2006 1:35:22)

AnyOne??????????????




jeepless -> RE: Sending checkbox to another page (2/8/2006 10:11:10)

quote:

We need to confirm what is happening on that second page

What happens when you do :

<%=response.write("software")%>


In Spooky's reply three steps up, shouldn't the correct code be:

<%=response.write(software)%> --ie, with quotes removed?

With the quotes, you're telling ASP to write the word "software" and that's exactly what it did but that wasn't the intention. I think he meant for the ASP code to write the value of the variable "software" to see what's being passed to the second page.

Try the corrected code in your second page, then post back what was sent.






wizard_oz -> RE: Sending checkbox to another page (2/9/2006 8:35:37)

OK, And then what? if I would like to print all the results for this software I should I do it?I can't use loop or something like that




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625