|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
||||
|
||||
|
using form field names in If statements
I tried posting this a minute ago but timed out, so sorry if this is posted twice.
I want to make an IF statement in ASP using VBscript that will run if a checkbox in a form is checked (and won't otherwise). How do i refer to the form field (checkbox) in the IF statement to do this? Thanks |
|
#2
|
|||
|
|||
|
It depends on how the form is submitted. If you are posting the form, then use:
Code:
If Request.Form("checkbox_name") = "testvalue" then
'execute some code
end if.
If you are using the get method, then use Code:
If Request.QueryString("checkbox_name") = "testvalue" then
'execute some code
End if
![]() hope this helps
__________________
How can I soar like an eagle when I'm flying with turkey's? |
|
#3
|
||||
|
||||
|
what do i use for "testvalue"? is it called "checked", or is there a different value for a checkbox that is checked?
|
|
#4
|
||||
|
||||
|
and i'm double posting, but thats ok...
Will the method Mohecan posted work if the checkbox is on a different page? the asp page the if statements are on is a different file than the form itself (the "action" parameter for the form is "AllRequest.asp", the page with the if statements. this is kinda urgent. :-) |
|
#5
|
|||
|
|||
|
When you put checkbox's on your form, you assign it a value.
When the checkbox is checked, it returns the value you assign it. Code:
<input type="checkbox" name="mycheckbox" value="abcde"> if the user checks this box, it will send the value abcde to the page listed in the action part of the form declaration, if the box is not checked, no value will be sent. The "post" method I described earlier will work in your instance, as I assume your form method is set to post. To retrieve the value in AllRequest.asp use the following: Code:
<% 'test whether user checked the box
If Request.Form("mycheckbox") = "abcde" Then
'user has checked the box, put your code here if the box was checked
else
'box was not checked, put your code here for when the box is not check
end if
%>
Hope this helps. |
|
#6
|
||||
|
||||
|
i figured it out finally, just the way you said here mohecan. thanks a bunch
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > using form field names in If statements |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|