Hi Friends

I have a form having multiple field such as option button set and checkbox with different names and values and on next page i want to get there name and value. The problem is that if i only use/checked option button i got proper names of object (option button) and there values but once i checked option button and checkbox too i got some of the values twice also on wrong possition on next page why ?

here is my form and codes for you

Form

<form action="Survey_Saved.asp" method="post">
<table width="876" border="1" cellpadding="1" bordercolor="#000000" class="style11">
<tr class="style11"><td width="325"><strong>Question Detail</span></strong></td>
<td width="146"><div align="center"><strong>Completely Disagree</strong></div></td>
<td width="71"><div align="center"><strong>&nbsp;Disagree</strong></div></td>
<td width="55"><div align="center"><strong>Agree</strong></div></td>
<td width="120"><strong>Completely Agree</strong></td>
<td width="119"><div align="left"><strong>&nbsp;Best Question </strong></div></td>
<tr class=style11><td>My work is interesting and I am committed to it. ?</td><td><div align=center><input name=Qst1 type=radio value=1></div></td><td><div align=center><input name=Qst1 type=radio value=2></div></td><td><div align=center><input name=Qst1 type=radio value=3></div></td><td><div align=center><input name=Qst1 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=1></td></tr><tr class=style11><td>I am clear about what is included in my working tasks. ?</td><td><div align=center><input name=Qst2 type=radio value=1></div></td><td><div align=center><input name=Qst2 type=radio value=2></div></td><td><div align=center><input name=Qst2 type=radio value=3></div></td><td><div align=center><input name=Qst2 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=2></td></tr><tr class=style11><td>I am being developed in my job. ?</td><td><div align=center><input name=Qst3 type=radio value=1></div></td><td><div align=center><input name=Qst3 type=radio value=2></div></td><td><div align=center><input name=Qst3 type=radio value=3></div></td><td><div align=center><input name=Qst3 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=3></td></tr><tr class=style11><td>I feel that I can influence matters which concern my working situation. ?</td><td><div align=center><input name=Qst4 type=radio value=1></div></td><td><div align=center><input name=Qst4 type=radio value=2></div></td><td><div align=center><input name=Qst4 type=radio value=3></div></td><td><div align=center><input name=Qst4 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=4></td></tr>
</table>
End of Section
<INPUT TYPE="submit" VALUE="SAVEINFO">
</form>

Codes to get values and names on next page

For Each field in Request.Form
Response.Write(field & " = " & Request.Form(field) & "<br>")
Next

Recommended Answers

All 16 Replies

hi,

I guess you want to pass the values to next page in that case append your values as querystring and redirect to the page

hi,

I guess you want to pass the values to next page in that case append your values as querystring and redirect to the page

Hi Nikie
Thanks for your reply but sorry to say i cant understand what you want to say, because i already said that i am able to get the value on next page but the problem is when i select any of the check boxes along with option button then i got wrong values as a i mentioned in my previous message. So please explain me what you want to suggest

Groups of radio boxes are allowed to have the same name because they are mutually exclusive. However, the checkboxes each have independent state (i.e., checking one does not uncheck another), so they should all have unique names. Then they will be passed appropriately instead of appended as an array. The point of the radio buttons having the same name is so the browser can recognize them as a group, but this doesn't apply to checkboxes.

Example form input's:

...
<input name=chk1 type=checkbox />
<input name=chk2 type=checkbox />
<input name=chk3 type=checkbox />
...

Example ASP processing code:

if request.form("chk1") = "on" then
  ' do stuff if chk1 is checked
end if
if request.form("chk2") = "on" then
  ' do stuff if chk2 is checked
end if
if request.form("chk3") = "on" then
  ' do stuff if chk3 is checked
end if

You also don't need to supply the "value" attribute of the checkboxes, because they have no value like radio buttons. They just have on / off states.

~ mellamokb

Hi

Thanks mellamokb for your reply, Well i understand what you trying to say but the thing is that if you look into my example i don't use any indivisual form element name i just use FOR EACH ITEM LOOP to call the values of the items of my previous form page.

So wat I want is I had few option buttons and few checkboxes and i want to got the values by using above loop.

Any way thanks for your suggetion

Ferhat

Qst1 = 1
Qst2 = 3
Qst3 = 3
Qst4 = 2
Best_Qst = 1, 4

Do u want ur reply in this manner?
I mean "after checking all the options u want to display the "Best_Qst".
Right?

No no i dont want to display the Best_Qst = 1, 4
actually these are the name and value of radio and checkbox that is wrong. If you look into my form no where i am trying to get the result in this way

if u could tell me what exactly u want then I can help u around.

thanx,
Shaielsh

Hi Friend

Actually my problem is that , I want to get value and the name of the different type of form element such as a set of option button and a checkbox. Actually when i only select any option button set and submit the form I got correct value and names of the object. But one I check any of the checkboxes available on the form. The result was in correct. For your better understanding below is my form and my asp page codes to get the value and name.

If you simply saved the same and run and try once by only selecting only option button and then select both and submit again you will find the deferene

I hope that you understand and thanks in advance

Form

<form action="Survey_Saved.asp" method="post">
<table width="876" border="1" cellpadding="1" bordercolor="#000000" class="style11">
<tr class="style11"><td width="325"><strong>Question Detail</span></strong></td>
<td width="146"><div align="center"><strong>Completely Disagree</strong></div></td>
<td width="71"><div align="center"><strong>&nbsp;Disagree</strong></div></td>
<td width="55"><div align="center"><strong>Agree</strong></div></td>
<td width="120"><strong>Completely Agree</strong></td>
<td width="119"><div align="left"><strong>&nbsp;Best Question </strong></div></td>
<tr class=style11><td>My work is interesting and I am committed to it. ?</td><td><div align=center><input name=Qst1 type=radio value=1></div></td><td><div align=center><input name=Qst1 type=radio value=2></div></td><td><div align=center><input name=Qst1 type=radio value=3></div></td><td><div align=center><input name=Qst1 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=1></td></tr><tr class=style11><td>I am clear about what is included in my working tasks. ?</td><td><div align=center><input name=Qst2 type=radio value=1></div></td><td><div align=center><input name=Qst2 type=radio value=2></div></td><td><div align=center><input name=Qst2 type=radio value=3></div></td><td><div align=center><input name=Qst2 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=2></td></tr><tr class=style11><td>I am being developed in my job. ?</td><td><div align=center><input name=Qst3 type=radio value=1></div></td><td><div align=center><input name=Qst3 type=radio value=2></div></td><td><div align=center><input name=Qst3 type=radio value=3></div></td><td><div align=center><input name=Qst3 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=3></td></tr><tr class=style11><td>I feel that I can influence matters which concern my working situation. ?</td><td><div align=center><input name=Qst4 type=radio value=1></div></td><td><div align=center><input name=Qst4 type=radio value=2></div></td><td><div align=center><input name=Qst4 type=radio value=3></div></td><td><div align=center><input name=Qst4 type=radio value=4></div></td><td><input name=Best_Qst type=Checkbox value=4></td></tr>
</table>
End of Section
<INPUT TYPE="submit" VALUE="SAVEINFO">
</form>

Codes to get values and names on next page

For Each field in Request.Form
Response.Write(field & " = " & Request.Form(field) & "<br>")
Next

if u could tell me what exactly u want then I can help u around.

thanx,
Shaielsh

Qst1 = 1
Qst2 = 3
Qst3 = 3
Qst4 = 2
Best_Qst = 1, 4

what I understood is U dont want to display the last line
"Best_Qst = 1, 4". Is it?

OR u tell me, after checking any of the checkbox together with option button what u want to display on the screen?

unless & until u change the status of the ckeckbox from unchecked to checked, it wont return any value.

That's why it is not showing other checkbox's names & values like option button. That's the difference.

Yes you right I know I need to check every check box if i want to get values of all checkboxes but the thing is that; here i dont want to get value of all check boxes.

Actually what i trying to say that when i do not select checkbox and press submit button it give me the value of all option button sets with their name and not showing name and values of checkbox thats ok , but once i checked on any of the checkbox along with option button its show incorrect values multiple. As far i concern the result should be like that

Qst1 = 1
Qst2 = 3
Qst3 = 3
Qst4 = 2
and after that it show that best quest check boxes values and names i think you understand now what i want to get.

can you please tried to run this form on your page and tried to check by yourself

The name of all checkboxes must be different.
Best_Qst1
Best_Qst2 like this
try this

Well i tried to do the same as you advise. The result is like
Qst1 = 1
Best_Qst1 = 1
Qst3 = 3
Submit = Submit
Qst2 = 2
Qst4 = 4

I had checked only one checkbox. The result is look closer as i wish thanks friend.

Can u still give me some advise regarding the same by looking the same result because it show the submit button value and name too.

give some name to submit button and

For Each field in Request.Form
if field<>"Submit" then
Response.Write(field & " = " & Request.Form(field) & "<br>")
end if
Next

it can be a field<>"submit" OR
field.name<>"submit"

check it out

Dear Friend

I dont know much about you like what's your name and ..... But any way you really resolved my problem. I really thank full to you for your support and interest.

I wish i become your good freind My name is Ferhat Male from Pakistan (Karachi)

:cool: its ok...

U can call me shailesh

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.