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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with script?

Status
Not open for further replies.

croiva25

Technical User
Dec 3, 2003
125
AU
We work in ASP VBScript pages.

When a check box is ticked at that moment I need to be able to have certain values selected in two drop down lists, so all of this exists at the moment and works but it has to be done manually, since it is all connected it would be good if it had the values selected when the check box was ticked.



I populate values for drop down lists in the following way,select the ID but display the description.


Nature of Problem</H1>
</TD><TD colspan=5 >
<SELECT id=natureOfProblem language=javascript onkeypress="return HandleTypeAhead(window.thisForm.natureOfProblem)">
<OPTION value="0"> </OPTION>
<%


Dim rsProblems

set rsProblems = CreateObject("ADODB.recordset")
call rsProblems.Open("SELECT Value, Description FROM Trim.dbo.viewZProblems ", myCon)

do while not rsProblems.EOF
Response.Write("<OPTION value=" & rsProblems("Value"))
if rsProblems("Value") = szProblemValue then
Response.Write(" selected")
end if
Response.Write(">" & _
rsProblems("Description") & "</OPTION>" & Chr(10))
rsProblems.MoveNext
loop

rsProblems.Close

%>
</SELECT>



What I was thinking of doing and I can't seem to execute that is to create OnClick() function and assign it to the check box so when it gets checked it selects these values.



Function onchange(){



window.thisForm.option1.value = 'whatever';

window.thisForm.option2.value = 'whatever';

}



So I don't know if this would work and if it would do I assign the number that represents the ID of the value i want to see selected on click.For example if i want to see "blah" selected and blah has an ID of 10 would I do it

"window.thisForm.option1.value = '10'



Could somebody advise me on this please?
 
What does the output of the ASP look like? onchange is the name of an event handler, so shouldn't be used as the name of a function.

Also, Javascript is case sensitive, so you need to make sure Function is spelled as function, otherwise it won't be processed like you want it to be.

Lee
 
I know JavaScript is case sensitive that was just an example for whoever helps me to get an idea of what I would like to do.

Output of the NatureOfProblem dropdown list is text "Insurance Claim" but it has the ID = 12 and so on.

Sorry I made a mistake it should go on the "onclick" event

Are you able to help me know
 
If you give imaginary examples, you'll get imaginary solutions. If you don't post the REAL code, then there's a good chance you're wasting your time and the time of the people here who try to help you. You need to copy and paste what you're working with, and not type it in new. Any typos you make or correct typing the code in this forum will create confusion and won't help solve your problem.

Lee
 
Thanks for your help and sorry I don't actually have any javascript at the moment I am asking for an idea,sample code acording to my needs if I am explaining myself properly and coming across clearly.

I have given the asp code where I showed how I populate one of the drop down lists and you can see from this query

call rsProblems.Open("SELECT Value, Description FROM Trim.dbo.viewZProblems ", myCon)

that fieldname "Value" represents the ID of the items listed and Description are their text values and now I need to have one value selected when a check box is ticked and that value has an ID of 12 and i am asking how to do so.

Check box ticked - how to have selected value that has and ID=12???

 
Form element values don't have IDs.

selected value that has and ID=12

Did you mean an option has a value of 12?

As well, you didn't supply the HTML that your ASP outputs. As I said, you give imaginary code, there's a good chance you won't get real answers. You need to come up with SOMETHING yourself rather than expect free programming done for you.

Lee
 
Look don't worry about,thanks for your time I didn't mean to waste any of it.

Just so you know I am in the process of learing Javascript and excuse me if I am not able to convert my knowledge into what I need to do and what I was aking help on.

Have a nice day
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top