Checking input

Results 1 to 4 of 4

Thread: Checking input

  1. #1
    yannick Guest

    Default Checking input

    Here&#039s my question, i can&#039t figure it out by myself (trust me i&#039ve been trying)<BR><BR>my situation (i&#039ll try to make it as clear as possible):<BR>I have an asp page that generates a form with several checkboxes. The names of these checkboxes are based on a IDnumber, so if the form has 5 boxes their names could for example be 141, 232, 263, 434 and 523....If a box is checked, it&#039s value will be "ON", if it&#039s not, it will not be passed when submitting the form.<BR><BR>So...for example when on the first page i check the boxes with the names 123, and 432...and after that i press submit, the next ASP page would have to deal with the following querystring:<BR><BR>whatever.asp?123=on&432=on<BR> <BR>in another situation the string could be:<BR><BR>whatever.asp?251=on&632=on&755=on&811=o n<BR><BR>and when no boxes are checked it would be:<BR><BR>whatever.asp?<BR><BR>now my question is:<BR>How could i program a piece of vbscript code that covers all situations and response.writes(to start with) which boxes were checked in the previous page.<BR><BR>The biggest problem with this is that i don&#039t know how many parameters to expect.<BR><BR>some extra info:<BR>I don&#039t have(like the id&#039s would imply)800 checkboxes on the first page...this page is also based on a previous page so the amount of boxes will vary.<BR><BR>Ok, does this make any sense ?<BR><BR>Thanks to anyone who&#039s willing to give me a hint on this...<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Checking input

    Try the following:<BR><BR>Dim theitem<BR>For Each theitem in Request.Querystring<BR> Response.Write Request.QueryString(theitem) & "<BR>"<BR>Next<BR><BR>Does this help?

  3. #3
    yannick Guest

    Default Yup, that's it

    that&#039s exactly what i was looking for.<BR>I didn&#039t know the for each statement could be used in combination with the querystring.<BR><BR>Just great ! thanks ;)

  4. #4
    Anil Tumati Guest

    Default RE: Checking input

    Hey Boss , Here is the Solution . I have added the Code,<BR>But Let me give a explination - i am checking all the elements in the form whose type is checkbox and also checking whether they are checked or not , if they are checked i am concatinating into a string and submitting the page (mean to say all the numbers which are on) - all u need to take care is to parse them in ur VBScript code ( I will also tell u how to parse , search for the comma and assign all the values into a vbs array and then use them)<BR><BR>var intcheck; // Intializing a variable to count the number of records which are Checked<BR>intcheck = 0;<BR>var listtosend ; // Intializing a variable which contains the list of ids which were selected<BR>listtosend = 0; <BR><BR>for(var i=0;i&#060;document.formname.length;i++)<BR>{<BR>i f (document.formname.elements[i].type=="checkbox" && document.formname.elements[i].checked==true ) <BR>{<BR>intcheck+=1;<BR>listtosend =listtosend +&#039,&#039+document.formname.elements[i].ID<BR>}<BR>}<BR><BR>If (intcheck == 0)<BR>{<BR> alert("Hello Boss U Have Not Selected Anything")<BR>}<BR>else<BR>var str ;<BR>str = "ToPage.asp?Sending?"+ listtosend <BR>document.formname.action = str<BR>document.formname.submit();<BR>}

Posting Permissions

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