Link to home
Start Free TrialLog in
Avatar of meirulexite
meirulexite

asked on

xmlhttprequest action

Hello,

I have a page full with checkboxes, each with a diffrent value and name,
I want to have a xmlhttprequest action, when a user clicks on the check box, an action will be made (query on a db)
then the checkbox will change to a select field with a similar name.
WITHOUT having to refresh the page..

Curently I have them side by side:

<input type="checkbox" title="CName1"><Select name="SName1"><option.....></select>
<input type="checkbox" title="CName2"><Select name="SName2"><option.....></select>
<input type="checkbox" title="CName3"><Select name="SName3"><option.....></select>
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Assuming
  theCheck.value+'.csv'
is the url of the request and it returns something like
val1,opt1
val2,opt2
val3,opt3
Avatar of meirulexite
meirulexite

ASKER

I'm new to xml requests... what is the csv file?
where do I put the db query?
is it on a diffrent file?
can I put it on the same file? I have some data that is for each opened page....
assuming your db queries are
/myquery.asp?param=query1
/myquery.asp?param=query2
/myquery.asp?param=query3

then you change

makeRequest(theCheck.value+'.csv');

to

makeRequest("/myquery.asp?param="+theCheck.value)

and change the html to

<form>
<span id="CName1div"><input type="checkbox" name="CName1" value="query1" onClick="ask(this)">1</span>
<span id="CName2div"><input type="checkbox" name="CName2" value="query2" onClick="ask(this)">2</span>
<span id="CName3div"><input type="checkbox" name="CName3" value="query3" onClick="ask(this)">3</span>
</form>

That is all.
The server process myquery.asp will then have to look at the parameter called param and execute the corresponding query.
It will then return the result as text/plain with linefeed between the text,value lines it produces

The csv files was just Comma Separated Values to test the process from static files