ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 7th, 2003, 11:56 PM
aspkid aspkid is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Memphis
Posts: 12 aspkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post checkbox problem

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

Reply With Quote
  #2  
Old October 8th, 2003, 12:40 AM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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?

Reply With Quote
  #4  
Old October 8th, 2003, 02:30 AM
aspkid aspkid is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Memphis
Posts: 12 aspkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #5  
Old October 8th, 2003, 02:32 AM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
no the code won't work, you still need to access the individual element in the array

i.e.
check = Request.Form("checkboxname")("elementnumber")

Reply With Quote
  #6  
Old October 8th, 2003, 07:27 AM
aspkid aspkid is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Memphis
Posts: 12 aspkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok fine Mohecan !! Can you put some light how can i tackle the things when the user selected more then one checkbox ?

Reply With Quote
  #7  
Old October 8th, 2003, 08:53 AM
aspkid aspkid is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Memphis
Posts: 12 aspkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem is fixed now.

Thanks for your anticipations.

Reply With Quote
  #8  
Old October 8th, 2003, 11:05 AM
aspkid aspkid is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Memphis
Posts: 12 aspkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 ?

Reply With Quote
  #9  
Old October 8th, 2003, 06:11 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Do you want to validate at the client side or at the server?

Reply With Quote
  #10  
Old October 9th, 2003, 01:44 AM
aspkid aspkid is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Memphis
Posts: 12 aspkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 ???

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > checkbox problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway