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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mdock
    New Member
    • Nov 2007
    • 12

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

    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:
    Code:
    Grid1.colData[8] = 'shipped(rsProduction.fields.getValue(\'Order_No\'))';
    Here is the vbscript function:
    Code:
    function shipped(order_no)
     if order_no=0 then
     shipped=""
     else
     shipped=""<A HREF=Historical_Order.asp?Order_No=" + rsProduction.fields.getValue(\'Order_No\') + ">" + rsProduction.fields.getValue(\'Order_No\') +"</a>""
     end if
    end function
    Here is the error the page returns:
    Code:
    [size=2] [/size]
    
    
    Microsoft VBScript compilation [font=Arial][size=2]error '800a0401'[/size][/font][font=Times New Roman][size=3] [/size][/font]
    
    [font=Arial][size=2]Expected end of statement[/size][/font] 
    
    [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:
    Code:
    Grid1.colData[8] = '"<A HREF=Historical_Order.asp?Order_No=" + rsProduction.fields.getValue(\'Order_No\') + "> " + rsProduction.fields.getValue(\'Order_No\') +"</a>"';
    Help...?
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    you have too many quote marks. Try this.
    [code=asp]dim q
    q = chr(34)
    function shipped(order_n o)
    if order_no=0 then
    shipped=""
    else
    shipped="<A HREF=" & q & "Historical_Ord er.asp?Order_No ="
    shipped = shipped & rsProduction.fi elds.getValue(\ 'Order_No\') & q & ">"
    shipped = shipped & rsProduction.fi elds.getValue(\ 'Order_No\') & "</a>"
    end if
    end function[/code]Let me know if it helps.

    Jared

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      or if you can't use quote marks, [code=asp]q = "'"[/code] is the next thing I would suggest

      Comment

      Working...