We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Fast answer please....How to use VBScript to check FormValues

erot asked
Medium Priority
Last Modified: 2010-04-09
I use an ASP-page to generate a page consisting of:
One frame consisting of unknown numbers of CheckBoxes
(because they are generated dynamically), some other text-
fields and a submit-button.

When the Submit-button are choosed by the user I want,
on the Click-event on that button, to generate a comma-
separated string of the names of the checked CheckBoxes and
put the string in a hidden text-field in the same frame.

I want all this done before the click on the submit-button
gives control to the ASP-page in the form's ACTION.

Short: I'm looking for a way to go trough all the checked
CheckBoxes without knowing in beforehand how many checkBoxes
there are, and generate a Comma-separated list of the Check-
boxes name,before the control are given to the ASP-file with the submit-button.
 Is this possible to do?????

I know about the request.form syntax that can be used in
ASP-page referenced in the form's ACTION, but this is not
the best solution for me.
                If there is a solution to this.... this
          question will be upgraded to 150 pnts if it can
        solve my problem.

Good luck. I use FrontPage98, ASP, Access and VBScript.
If it's not possible in VBScript...what about other scripts
such as Java-script??

Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)

hmm i had not read your title that good, it is javascript not vbscript

I solved your problem, and it is possible, you make as many checkboxes as you need in one form and make a second form, you'd submit that makes the comma seperated list.
A for-loop makes sure you dont have to know how many there are just give them the same
name and an array is made.

here is the code:

function join()
 var val,i;
 val = "";
   if (document.form1.my_chk[i].checked)
     val += document.form1.my_chk[i].value + ",";
 // save it in the hidden field of the other form
 document.form2.my_chk_list.value = val;


<FORM NAME=form1>
<!-- and even more checkboxes named my_chk -->


<FORM NAME=form2 method=POST onsubmit="alert('submitting: list = '+                                                                          document.form2.my_chk_list.value)">
<INPUT TYPE=SUBMIT Onclick="join()" VALUE="Submit">

let those 150 pnts come if you like my solution


O well let Erot fight out who gets the points

Sybe and I haven't seen each others answers and answered the question independetly

mayby you can share the points, Erot, post a question for Bluemoon in the same group for part of the points or ask the EE.



I'm still waiting for the book to arrive...I don't have the
syntax of VBScript.
(By the way...do you know any good ASP books for professionals.
I have ordered : Professional Active Server Pages 2.0 (Wrox))

Back to my problem....
Can you please send me the syntax for the
   FORM GET Method....
   If there is a difference between the syntax in a called
   ASP-file and feks if the code on a buttons Click-event please
   show me both syntaxes.


This was To Sybe.

Can you please send me the syntax for the
   FORM GET Method....
   If there is a difference between the syntax in a called
   ASP-file and feks if the code on a buttons Click-event please
   show me both syntaxes.

I am not sure if I understand your question now. But I'll try to answer it:

1. Submitting a form can be done by "POST" and by "GET". GET is default. GET produces a querystring, POST sends the data to the server from which they can be gotten by "asking" the server in your script. To indicate what you want to do with the from, it should be included in the form-tag (with method=...):
<FORM action="your_page.asp" METHOD="GET">

2. When a form is submitted to an ASP, then that ASP can use the formdata which have been submitted. When the method was "GET", then the formdata can be fetched by Request.Querystring("name_of_the_form_field").
If the method was POST then it is:

If you are not sure about the method, you can use Request("name_of_the_formfield")

I hope this answers your questions, but again, I am not sure what you ask.


Thank You Sybe and Bluemoon...
You to have been very energic  ....
I can see that the question can be missunderstood?!?!?!

Even shorter: Before the form is submitted I want to put a
  commas-eparated list of the names of """only""" the checked
  Check-boxes and put the result in a hidden field in the form.
  As posted before I do not know the names of the check-boxes
  on the form or how many, when I write the script...so the
  script have to be general.

Thank you for your answer so far...I'l try to figure out if the
answers you have given me can be used..Then I'l come back to you.


Ok, check the answers given, and see if they do.

I still think that there is a better way to achieve what you want then with the way you want to solve it. But then again, I don't know exactly what you want to achieve.

It would be helpful if you'd post the ASP-code of the page that generates the form with the checkboxes, and the code of the page that will process the formdata. I guess that will make clear what you want to achieve.


this code works perfectly well on the corresponding ASP-page
on the server.

dim checkValues
checkValues = request.form("C1")
'where C1 are the names of all the checkBoxes on the page.
if the client checked any of the CheckBoxes the variable
checkValues are equal to a commaseparate string of the values
to the checked CheckBoxes.  But is it really not possible to
produce the same commaseparated string with code running on
the client (script within the page that are shown on the client).
If it was it would simplify my code a great deal.

The reason... I want to verify what the user checked, give him
a message where he can submit or cancel. I want to show this message in a messageBox not a new Page...


If you don't know the names of the checkboxes, the method Sybe used would work
and if you like the have 'only' the hidden value, you would have to use a seperate form
you can even remove the text the 'submit' button sends by making it a normal button
and at the end of the javascript something like



Sybe and bluemon...Thank you for answering...
Can't do much about the delivery of points.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.