Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Checkbox group

sorry for being annoying, but the problem persists.
i have auto generated a group of checkboxes with the same name
//...code
Response.Write(""+recordset("CName")+"");
//..code
now if the user submits, he will be taken to an asp page that will validate his input, and HE IS NOT forced to check any check box.
the problem is what should i do to know if the user didn't check anything and how,if he did, to separate the values that are stored.
//..anotherpage.asp
courses=Request.Form("courses");
for (var element in courses)
sql3=sql3 & "insert into Courses values( '"+id+", '"+courses(element)+"') ";
//..code
i tried this but it didnot give any results. so plz can anybody help meeeeeeeeeee...

Comments

  • aaronjones3593aaronjones3593 Member Posts: 122
    [b][red]This message was edited by aaronjones3593 at 2005-11-12 10:46:42[/red][/b][hr]
    : sorry for being annoying, but the problem persists.
    : i have auto generated a group of checkboxes with the same name
    : //...code
    : Response.Write(""+recordset("CName")+"");
    : //..code
    : now if the user submits, he will be taken to an asp page that will validate his input, and HE IS NOT forced to check any check box.
    : the problem is what should i do to know if the user didn't check anything and how,if he did, to separate the values that are stored.
    : //..anotherpage.asp
    : courses=Request.Form("courses");
    : for (var element in courses)
    : sql3=sql3 & "insert into Courses values( '"+id+", '"+courses(element)+"') ";
    : //..code
    : i tried this but it didnot give any results. so plz can anybody help meeeeeeeeeee...
    :

    set the name of the checkboxes to whatever[], i mean, add [] to the end.

    then on the validating page refer to it as an array, for example:

    [code]
    One
    Two
    Three
    [/code]

    then in the asp page: ( With JScript )

    [code]
    <% @Language = "JavaScript" %>
    <%
    var something = cbox[0]; // First option (null if not checked)
    var something_else = cbox[1]; // Second option (null if not checked)
    var last_one_lol = cbox[2]; // 3rd option... u know the rest

    if (something == "one")
    {
    // First checkbox WAS checked
    }
    else
    {
    // First checkbox WAS NOT checked
    }
    %>
    [/code]


Sign In or Register to comment.