1

i have a form with 3 checkboxes in it and i need to perform some actions depending on selected checkbox values. So my current task is to get an array of selected values on server side using JScript. Here's a form

<form method ="post" action="table.asp" name="grades">
<input type="checkbox" value="2" name="cb" id="cb"> 2</input>
<br>
<input type="checkbox" value="3" name="cb" id="cb"> 3</input>
<br>
<input type="checkbox" value="4" name="cb" id="cb"> 4</input>
<br>
<input type ="submit" value=" Go">
</form>

I've managed to get a string which looks like cb=2&cb=3 using var cbstring = Request.form()

It seems like i can't split it with cbstring.split() method. When i add it server returns unspecified error message without any helpful info in it. Debug is set to true in web.config.

So any help with making things right will be greatly appreciated

1 Answer 1

1

Request.Form is an object (ASP's request dictionary) so it hasn't a split method. Fortunately Request.Form[(key)].Item is a string of serialized key or key/value pairs of the collection.
Have a look at https://stackoverflow.com/a/31444907/893670 to see how to handle Request collections in ASP w/ JScript, it might be helpful.
And here's a way to do what you want.

var arr = [];
if(Request.Form("cb").Item)
    arr = Request.Form("cb").Item.split(", ");
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, you realy helped!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.