[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Update database with asp when setting option on select

Posted on 2014-08-10
2
Medium Priority
?
443 Views
Last Modified: 2014-08-10
I have a script that has 2 multiple selects

<select multiple>
</select>

When the form is submitted it runs a script depending on the values of the select options selected.

Now.

The select options are created accesing a database.

The first one is quite simple. Open a table, scan the values for the <select multiple></select>

The tricky part is:

The second select scans a recordset  but the sql query depends on the values set on the first select.

Say the first select has students and the second has subjects, we want to select from all the students (one or more) in the first <select name="students" multiple></select> and in the second open a record set like:

select * from subjects,students where students.ok=1 (assuming the students table has an ok field which is set in the first select)

What is required is that when a value is set (on or off) in the first select the table of students is updated with ok=1 (is set on) or ok=0 (if set off).

I realize that javascript will run a js function with the onchange event. But I have no Idea if how to change the databse values (first select. update students set ok=1 where...)

Of course the whole purpose is to not run the form in order to update the vaues and then populate the second <select name="subjects" multiple></select>.

I need it to be a one step script.

The two <select></select> are in a form that when submitted it runs a script that uses the data from the values set in the form.
0
Comment
Question by:robrodp
2 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 40251769
You're looking for cascading dropdown, a similar question here :
http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_26498993.html

basicaly you need to create a script returning ONLY the result, depending the format you choose you will have more work to do.

for example if we call : yourpage.asp?ok=1
your script need to return result for ok=1 :
in HTML :
<option value="foo1">foo1</option>
<option value="foo2">foo2</option>
<option value="foo3">foo3</option>

in string CSV :
foo1,foo2,foo3

in JSON format:
[{"foo1":"foo1"},{"foo2":"foo2"},{"foo3":"foo3"}]
0
 

Author Closing Comment

by:robrodp
ID: 40251772
Exaclty what I was looking for Thz
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question