How to Reference a Javascript variable in Embedded

Results 1 to 2 of 2

Thread: How to Reference a Javascript variable in Embedded

  1. #1
    Join Date
    Dec 1969

    Default How to Reference a Javascript variable in Embedded

    We have written a function in Javascript that is called from the<BR>onchange event of a dropdown list on a form.<BR>The function receives the value of the dropdown as the user<BR>makes a new selection.<BR>The function has embedded ASP sql script that then refreshes<BR>another dropdown based on the functions argument.<BR>However, we cannot figure out how the embedded ASP SQL in the<BR>Javascript function reference the function&#039;s argument. We need it in the where clause of the SQL.<BR><BR>Here is the sample code:<BR>function makeList(client_id){<BR> &#060;%Set Conn = Server.CreateObject("ADODB.Connection")<BR> Conn.Open Application("database1_ConnectionString")<BR> <BR> sql = "select shift_id,shift_name FROM client_shift_lu WHERE client_id = " & "6"<BR> Set RS = Conn.Execute (sql)<BR> i = 0<BR> Do While Not rs.eof<BR> <BR> shift = rs("shift_name")%&#062;<BR> document.forms[0].shifts.options["&#060;%=i%&#062;"] = new Option("&#060;%=shift%&#062;");<BR> <BR> &#060;% RS.MoveNext<BR> i = i + 1<BR> loop<BR> <BR> RS.Close<BR> Conn.Close<BR> <BR> <BR> %&#062;<BR> <BR> document.forms[0].shifts.length = "&#060;%=i%&#062;"<BR><BR> }<BR>Note that in the Select statements where clause we currently have<BR>hardcoded 6 but we really want to use the client_id function argument.<BR><BR>Thanks<BR>rs

  2. #2
    Join Date
    Dec 1969

    Default RE: How to Reference a Javascript variable in Embe

    Erm, it seems to me that you have misunderstood the concept of server and client side scripting. It appears as if you&#039;ve wedged a block of server side script inside the client side JavaScript function, and are wondering why it doesn&#039;t work?!<BR><BR>What you will actually need to do is create a form of Remote Procedure Call, whereby you can invoke ASP type requests invisibly on the client and process the ASP output. There are a number of methods for doing this. I suggest you look here for starters.<BR><BR><BR><BR>Of course, I would be available to create this for you within your website for a negotiated fee :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts