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

include vbscript within javascript function

Status
Not open for further replies.

richey1

Technical User
Oct 5, 2004
184
0
0
GB
Hi

I have an asp form, with a select box (selService) and a text box (txtWebLink). the select box holds a series of values, that dependent on the value selected I want the text box to updated based on the select value.

I have a look-up table (CCCu_ServiceWebLinks) with 2 columns ServiceID,WebLink - with values such as
117,118,127,
say the user selects the value 117 from the select list (selService), I would like, using onblur for example, to go away, look up the corresponding value in CCCu_ServiceWebLinks and put in the text box.

my vbscript is something like this at the moment, but i want to do this using javascript so i can call the onblur event from the select box

any ideas ?

thanks


Code:
dim rsWebLink

set rsWebLink = Server.CreateObject("ADODB.Recordset")

dim lngServID, WebLink1

lngServID = Request("selService")

if isnull(lngServID) then
set rsWebLink = execqueryRS_X("CONN_W", "select * from CCCu_ServiceWebLinks where SERVICEID=0",null)
else
if lngServID = "" then
set rsWebLink = execqueryRS_X("CONN_W", "select * from CCCu_ServiceWebLinks where SERVICEID = 0",null)
else
set rsWebLink = execqueryRS_X("CONN_W", "select * from CCCu_ServiceWebLinks where SERVICEID = 

?",array(adnumeric,5,lngServID))
end if
end if

WebLink1 = rsWebLink("WEBLINK")
 
sorted it thanks using

Code:
	Response.Write "<script language=javascript>" & vbLf
	Response.Write "var arrTargets1 = new Array();" & vbLf

while not rsWebLink.eof
		if CLng(rsWebLink("ServiceID")) > 1 then
			Response.Write "arrTargets1[" & rsWebLink("ServiceID") & "]='" & rsWebLink("WebLink") & "';" & vbLf
		end if
		rsWebLink.MoveNext
	wend

	Response.Write "function selServiceChange()" & vbLf
	Response.Write "{" & vbLf
	response.write "  document.frmEnquiry.txtWebLink.value=arrTargets1[document.frmEnquiry.selService.value];" & vbLf
	Response.Write "}" & vbLf
	Response.Write "</script>" & vbLf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top