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

onChange Call URL 1

Status
Not open for further replies.

alexanderthegreat

IS-IT--Management
Sep 9, 2005
70
US
I need to apply a javascript onChange event to a drop down list called 'child' so that when it changes it passes to a url = main.asp?id=<%=(Recordset1.Fields.Item("iddir_dir").Value)%>

 
Code:
<select onchange="document.location='main.asp?id<%=(Recordset1.Fields.Item("iddir_dir").Value)%>'">

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
or, if you wanted to ensure that a certain option has to be selected first, you could add a conditional statement:
Code:
<select onchange="[!]if (this.selectedIndex == 2) {[/!]document.location='main.asp?id<%=(Recordset1.Fields.Item("iddir_dir").Value)%>'[!]}[/!]">
   <option>1</option>
   <option>2</option>
   <option>3</option>
</select>
Would trigger when the user selected the 3rd option in the dropdown. (first option has an index of 0)

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/alain/newadmin/main.asp, line 676, column 39
Response.Write((Recordset1.Fields.Item(\"iddir_dir\").Value))
--------------------------------------^

Line 676 is:

<td><select name="child" disabled="disabled" id="child" onChange="MM_callJS('\&quot;document.location=\'main.asp?id<%=(Recordset1.Fields.Item(\"iddir_dir\").Value)%>\'\&quot;&gt;')">
 
I dunno, i just copied/pasted that part from your original post because you said that is the link you want to open. I provided the javascript solution to open a new window when you change the value in the dropdown. For instance, this should work fine:

Code:
<select onchange="document.location='[!][URL unfurl="true"]http://www.google.com[/URL][/!]'">

Now.... I can point out some things that I think might be wrong with your code.

1) When I pull in info from a recordset in ASP I use the following syntax:

recordSetName.Fields("fieldName").value

so, you might want to remove Item from your pull.

2) You might want to make sure the recordset is open when you are trying to pull the data, although I think you would have gotten a different error if that was the case.

3) you are going to need an = sign if you are assigning this record value to the id identifier in the page call:

...main.asp?id[!]=[/!]<%=(Recor...


If that doesn't help you solve the problem then I'm not sure you can get anymore help from this forum. The javascript portion of your question has been solved (I think). You might wanna check the ASP forum for any further assistance.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top