Can you tell form input type with ASP?

Results 1 to 6 of 6

Thread: Can you tell form input type with ASP?

  1. #1
    Tom Mutdosch Guest

    Default Can you tell form input type with ASP?

    Is there a way that I can check whether an input type is of<BR>the checkbox on a form? I have a form with some checkboxes and<BR>a few text fields, and I only want to run the following subroutine on checkboxes only. Is there a check that I can do?<BR><BR>Sub isChecked( )<BR> if ( Request.Form( "Question" ) = "checked" )<BR> return = "Yes"<BR> else if ( Request.Form( "Question" ) = "" )<BR> return = "No"<BR> end if<BR>End Sub<BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    168

    Default RE: Can you tell form input type with ASP?

    Sub isChecked()<BR>if (CInt(Request.Form("Question") = "on") = -1) then <BR>return="Yes" <BR>else <BR>return="No" <BR>end if<BR>End Sub<BR><BR>Hope this helps... Cheers!

  3. #3
    Tom Mutdosch Guest

    Default RE: Can you tell form input type with ASP?

    What is the "clnt" call? It is undefined [type mismatch] whenever I try to use it. Do I need to include a header?

  4. #4
    BLooDSHOT Guest

    Default RE: Can you tell form input type with ASP?

    cInt is a way to change to an integer. It is cint... not cLnt.


  5. #5
    Tom Mutdosch Guest

    Default Not the checkbox so much, but more general input type

    My question is not so much on telling whether a checkbox is checked or not which the information previously provided accomplished; but rather how to tell the input type from the form. <BR>I have a form with both checkox&#039s and textarea&#039s. I want to have a general function that I call regardless, and I only want an action to take place if the input type from the form was a checkbox. Is there any way to do this? ie (in pseudocode):<BR>if input type is a checkbox<BR> if ( checked ) do this<BR> if ( not checked ) do this<BR>else <BR> do nothing<BR>endif<BR>

  6. #6
    Stephen Fisher Guest

    Default RE: Not the checkbox so much, but more general input type

    What I have started doing is using conventions when naming the inputs. Then I iterate through the request.form collection and parse the name and see what it was.<BR><BR>THe code below lists the names and values. If the name is chk_xxxxx than it is a checkbox, if txt_xxxxxx textarea ect.<BR><BR>For each item in Request.Form<BR> Response.Write "&#060;b>" & item & "&#060;/b>=" & Request.Form(item) & "<BR>"<BR>Next<BR><BR>This doesn&#039t answer your question bt I hope it helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •