By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

using a vbscript function to feed a hyperlink into a javascript grid on an ASP page

P: 12
Hello,

I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0.

Herein lies the problem; if the order number is 0, I do not want the grid to display anything. If the order number is not 0, I want it to display the order number as a hyperlink to the order.

I have been able to do one or the other, but not both. I can display the order number as a hyperlink. OR by calling a vbscript function, I can test the order number, and if it is 0, I can omit it from the grid.

However, I have had no success in trying to get the vbscript function to spit out a hyperlink if the order number is not 0. It seems I am close, but I can't get it formatted just right for input into the javascript code for the grid.

Here is the line of code from the javascript grid:
Expand|Select|Wrap|Line Numbers
  1. Grid1.colData[8] = 'shipped(rsProduction.fields.getValue(\'Order_No\'))';
Here is the vbscript function:
Expand|Select|Wrap|Line Numbers
  1. function shipped(order_no)
  2.  if order_no=0 then
  3.  shipped=""
  4.  else
  5.  shipped=""<A HREF=Historical_Order.asp?Order_No=" + rsProduction.fields.getValue(\'Order_No\') + ">" + rsProduction.fields.getValue(\'Order_No\') +"</a>""
  6.  end if
  7. end function
Here is the error the page returns:
Expand|Select|Wrap|Line Numbers
  1. [size=2] [/size]
  2.  
  3.  
  4. Microsoft VBScript compilation [font=Arial][size=2]error '800a0401'[/size][/font][font=Times New Roman][size=3] [/size][/font]
  5.  
  6. [font=Arial][size=2]Expected end of statement[/size][/font] 
  7.  
  8. [font=Arial][size=2]/BatchReportInfotest.asp[/size][/font][font=Arial][size=2], line 528[/size][/font] shipped=""<A HREF=Historical_Order.asp?Order_No=" + rsProduction.fields.getValue(\'Order_No\') + ">" + rsProduction.fields.getValue(\'Order_No\') +"</a>""-------------^
I have tried a mix of single and double quotations, etc. to try to get the hyperlink to feed properly into the grid code, but no such luck.

Here is the original working code from the javascript grid which did not test for the result of 0:
Expand|Select|Wrap|Line Numbers
  1. Grid1.colData[8] = '"<A HREF=Historical_Order.asp?Order_No=" + rsProduction.fields.getValue(\'Order_No\') + "> " + rsProduction.fields.getValue(\'Order_No\') +"</a>"';
Help...?
Mar 10 '08 #1
Share this Question
Share on Google+
2 Replies


jhardman
Expert 2.5K+
P: 3,405
you have too many quote marks. Try this.
Expand|Select|Wrap|Line Numbers
  1. dim q
  2. q = chr(34)
  3. function shipped(order_no)
  4.    if order_no=0 then
  5.       shipped=""
  6.    else
  7.       shipped="<A HREF=" & q & "Historical_Order.asp?Order_No="
  8.       shipped = shipped & rsProduction.fields.getValue(\'Order_No\') & q & ">"
  9.       shipped = shipped & rsProduction.fields.getValue(\'Order_No\') & "</a>"
  10.    end if
  11. end function
Let me know if it helps.

Jared
Mar 12 '08 #2

jhardman
Expert 2.5K+
P: 3,405
or if you can't use quote marks,
Expand|Select|Wrap|Line Numbers
  1. q = "'"
is the next thing I would suggest
Mar 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.