|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there !!
I am new born kid of this block and want some help from my seniours. I am populating the few fields values from one of the table. I put series of checkbox having same name but have a different value ( value of checkbox is small int, an autoincrement field of table). I have to take action against the selection of checkboxes. If the user check one of the checkboxes and select "Approved the things " then the USER will move to some else page and the selection will Approve. On the contrary, if the user opt delete the things then user move to other page and record will be delete from the table. Now my problems is... 1) how can I know which checkbox user selected ? 2) Are there someway to get the value of checkbox without making form ? With Thanks |
|
#2
|
|||
|
|||
|
1) So long as the checkbox's are all named the same, then upon form submittal, an array of checkboxname will be created.
such that Code:
Dim i
For i = 1 to Ubound(checkboxname)
'perform selected action on each item
' as checkboxname(i)
Next i
2) You must create a form in order for the values to be passed (either posted or get'ed) PS - depending on whether you post or get the data, access it as Request.QueryString("checkboxname") if you use get or Request.Form("checkboxname") if you use post
__________________
How can I soar like an eagle when I'm flying with turkey's? |
|
#3
|
||||
|
||||
|
|
|
#4
|
|||
|
|||
|
Thanks to Icepricessa for the URL and Mohecan for quick reply.
Can Request.Form("checkboxname") not work if I post the form viz... dim check as int check= requestform("checkboxname") Is the above code work or not ? provided all the checkbox has same name but different value, if i only need the value. |
|
#5
|
|||
|
|||
|
no the code won't work, you still need to access the individual element in the array
i.e. check = Request.Form("checkboxname")("elementnumber") |
|
#6
|
|||
|
|||
|
Ok fine Mohecan !! Can you put some light how can i tackle the things when the user selected more then one checkbox ?
|
|
#7
|
|||
|
|||
|
Problem is fixed now.
Thanks for your anticipations. |
|
#8
|
|||
|
|||
|
Hello to all again,
Can anyone let me know how can i validate wether the checkbox is checked or not in the earlier mention case ? |
|
#9
|
|||
|
|||
|
Do you want to validate at the client side or at the server?
|
|
#10
|
|||
|
|||
|
Though, i wish to code and check the things at both end but right now i am trying my hands and mind at client side.
I managed to code for the client side but the problem is it not working properly. I made one function is javascript that check wether any check box is checked or not. Function run poperly and showing me error msg aswell but after clicking the OK button of the msg it redirect me to the form redirection page which i not want in any case. Here is the code snippets:: <script language=javascript> function validatecheck(Name) { var f = document.forms[0]; var e = f.elements[Name]; var checkedQty = 0; for(i=0;i<e.length;i++) { if(e[i].checked) { checkedQty++; } } if(checkedQty < 1 ) { alert(" Error......"); return false; } } function validate() { validatecheck("Check"); } </script> <form name="accfrm" method="post" action="checkthefrm.asp"> ------ ------ <input type="submit" value="Approved Selection " name="Approved" onclick="validate()" style="font-family: Verdana; font-size: 8pt; color: #191970"> </form> Any help ??? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > checkbox problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|