Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML with SQL Server 2000

Status
Not open for further replies.

TenMinJoe

Programmer
Jan 24, 2002
3
GB
Hi. I need some help.

I want to display, in HTML, a subset of records from my SQL Server database, and a checkbox for each item. I want to allow the user to select an arbitrary amount of items, and then submit the results to SQL Server, whereupon it will process the results. For example, the user might select three records and choose 'delete'.

I can display the items in the browser just fine. But, I don't know how to deal with the user selecting more than one item. The Perl-style way is to give all the checkboxes the same 'name' attribute, and the submitted results arrive in the form of an array of their 'value' attributes. However, I don't know of a way to specify an array as an input parameter to an SQL stored procedure via an XML template.

Still reading? :)Any help appreciated...
 
Do you have server-side scripts?

One approach... When building the form, store the primary key for each row in a hidden input field. When the form is submitted issue separate deletes for each of the rows i.e. if the check box is on build the delete statement dynamically using the value of the hidden field.

This isn't an XML solution, just an old fashioned scripting solution.

 
Replying to my own problem here, having solved it, in case anyone else is trying something similar.

I have used JavaScript to compile the values of all the selected checkboxes into one input (of type 'hidden'). The javascript executes when the user clicks submit. So, all the selected items are munged together into one big parameter.

Now I just need to write some SQL code to unmunge the big parameter back into lots of little ones :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top