Dynamic Checkboxes & Event handling

D

DylanM

I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the boxes and saving to the database at the end with the 'Submit' command button.

Is it possible to save the changes as the checkboxes are clicked? I suppose I'd need to write some dynamic ASP event handling at the same time as creating the checkboxes...

So something like...

<td><input type = "checkbox" name = "chk<%= rstSearch("Product_Group") %>+<%= rstSearch("Depth_Flag") %>" > Select </td>

Function chk87101500
'// Event handler for dynamic checkbox above...
End Function

Scenario:
This is an internal IIS application for selecting stock to send to stores. The page with the checkboxes on is a top level summary, it shows how much is currently stocked / how much available etc. Each check box represents a product line and 'chart ranking', eg;

Feature Films DVD Ranked 1-100 50 Titles Available CheckBoxHere!
Rock & Pop CD Ranked 1-100 47 Titles Available CheckBoxHere!

Users click the checkboxes to select all the products within the line, so by clicking in the above example they would stock 50 or 47 titles. Next to each of these lines is a link to view the products in detail and only select certain ones, in a lot of cases they wouldn't want all 50. In the detail page, they select the titles they want, submit that form, then are redirected back to the summary page which is reloaded and all the totals updated.

Here's the problem! Because the page is being reloaded and changes haven't been committed to the database, I'm losing all of the ticks on the page. The user will work through the summary page ticking certain product lines, then come to a line which they want to view in detail. They go to the detail page, make changes, redirected to summary page & all their work so far has been lost!

I'm not sure on the best way to go about it? Either commit changes on the summary page as they are made or use session variables to keep record of the ticks the user has made? Any other suggestions?!

Thanks
 
C

CJM

You *can* update you DB when a user checks/unchecks a checkbox, however, you
can't use ASP to do this. ASP is a server-side technology and is blissfully
unaware of what is happening at the client-side.

You need to use a client-side technology, which is almost certainly going to
be Javascript. Bear in mind that 13% of browsers dont have Javascript or
have it disabled, so this wont be a perfect solution for all of your users.

I suggest you re-post your question to microsoft.public.scripting.jscript
NG.

hth

Chris
 
D

DylanM

Yeah sure, I understand that the event handling would be client-side, but surely from the event I could post info to server for ASP routine?

This is an intranet solution, don't have to worry about external users & their browser capabilities...!!

Alternatively, any other ways to keep track of what checkboxes the user has clicked so far, before a DB update has taken place? Session variables were an idea, but there could be lots of product lines & I wouldn't want to use too many?

Thanks
 
P

Phillip Windell

DylanM said:
Yeah sure, I understand that the event handling would be client-side, but
surely > from the event I could post info to server for ASP routine?

You would be causing it to "submit" the form with every checkbox "click"
which means it has to make a full round trip to the server and back and the
browser would have to reload the page completely everytime. It would take
forever to go down a list of checkboxes this way.
 
J

just1coder

How can I loop through checkboxes in an ASP? I want to fire a delete
function for each item that is checked off in a form ...
 
P

Phillip Windell

You use client-side script that submits the form using,.. I suppose,..the
OnChange() event of the checkbox.

I don't know anything about XML.

--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com


DylanM said:
It's an Intranet application running s'procs over an optimised SQL 2000
BE, gigabit network connection, performance is lightening! I understand that
it's not the best way to deal with data updates (& over an internet
connection would be suicidal!) . An 'all or nothing' transactional update at
the end would be best of course.
Do you have any suggestions for saving the check boxes status, which is my
main problem. Session variables? XML?
 
P

Phillip Windell

The check boxes have a name.
Retreive the values from each check box on the target ASP page that receives
the "submit".
Perform actions based on the values.
In other words they are no different than any other form input object in
that respect.

You don't loop through anything.
 
C

CJM

Phillip Windell said:
You use client-side script that submits the form using,.. I suppose,..the
OnChange() event of the checkbox.

I don't know anything about XML.

Actually, one solution to consider is using an XMLHTTP object to call
another ASP page to update the DB. It's client-side Javascipt that does the
calling, but ASP that does the DB access:

There are numerous examples listed on Google, but one example I found was
this:
http://jibbering.com/2002/4/httprequest.html

Look half way down - "Calling a server-side Script without refreshing the
page"

Chris
 
J

just1coder

You'd be better off building a single delete SQL statement for all of
your variables in one go, rather than executing multiple Delete
statements....but you get the idea!

Could you give me an example?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top