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

Passing outside variable into JS.

Status
Not open for further replies.

timmbo

Programmer
Feb 22, 2001
167
US
Hope you gurus can help me. I am passing a variable, gstrRptTitle, from a reporting tool into a method, Sub Start, containing JS loaded into a string. This string, dhtmlCode, is utimitely passed to the web as a link. The problem is gstrRptTitle is not being populated. I confirmed that gstrRptTitle does get passed to Sub Start and is populated there. But when loading it to JS, it caused an "undefined" error. I'm pretty sure it has something to do with my quotes placement or lack of. But not sure as to where they need to be. If anyone can help me out here, I would surely appreciate it.

The error is caused at the bolded line.

[c]
Sub Start( )

Super::Start( )

ShowFactoryStatus("Export Title .... " & gstrRptTitle)

dhtmlCode = "<FORM NAME=""Export""> " & chr$(10)
dhtmlCode = dhtmlCode & "<SCRIPT LANGUAGE=""JavaScript""> " & chr$(10)
dhtmlCode = dhtmlCode & "function detectBrowser() { " & chr$(10)
'dhtmlCode = dhtmlCode & "alert(""Start Browser Code""); " & chr$(10)
dhtmlCode = dhtmlCode & "var bUserAgent = navigator.userAgent; " & chr$(10)
dhtmlCode = dhtmlCode & "var mypos = bUserAgent.search(/MSIE/i) " & chr$(10)
dhtmlCode = dhtmlCode & "var myVersion = bUserAgent.substring(mypos + 5,33); " & chr$(10)
dhtmlCode = dhtmlCode & "if (myVersion < 5.5) { " & chr$(10)
dhtmlCode = dhtmlCode & "var msg = ""Your current version of Internet Explorer is "" "& chr$(10)
dhtmlCode = dhtmlCode & "+ myVersion + "".\n\n"" + "& chr$(10)
dhtmlCode = dhtmlCode & """You MUST have version 5.5 or above to use this feature."" "& chr$(10)
dhtmlCode = dhtmlCode & "alert(msg); " & chr$(10)
dhtmlCode = dhtmlCode & "} else { "& chr$(10)
dhtmlCode = dhtmlCode & "var idx = document.URL.indexOf('?'); " & chr$(10)
dhtmlCode = dhtmlCode & "var params = new Array(); " & chr$(10)
dhtmlCode = dhtmlCode & "if (idx != -1) { " & chr$(10)
dhtmlCode = dhtmlCode & "var pairs = document.URL.substring(idx+1, document.URL.length).split('&'); " & chr$(10)
dhtmlCode = dhtmlCode & "for (var i=0; i<pairs.length; i++) { " & chr$(10)
dhtmlCode = dhtmlCode & "nameVal = pairs.split('='); " & chr$(10)
dhtmlCode = dhtmlCode & "params[nameVal[0]] = nameVal[1]; " & chr$(10)
dhtmlCode = dhtmlCode & "} " & chr$(10)
dhtmlCode = dhtmlCode & "} " & chr$(10)
dhtmlCode = dhtmlCode & "connhandle = params[""connectionHandle""] ? params[""connectionHandle""] : """"; " & chr$(10)
dhtmlCode = dhtmlCode & "id = params[""id""] ? params[""id""] : """"; " & chr$(10)
dhtmlCode = dhtmlCode & "alert(""Browser Code 1""); " & chr$(10)

dhtmlCode = dhtmlCode & "self.location.href=""../viewer/searchreportpage.jsp?id="" + id + ""&connectionhandle="" + connhandle + ""&name="" + gstrRptTitle + "".roi&format=CSV&startingPoint=0&Pooled_Sweep::F3::AcctNum:select=true&Pooled_Sweep::F3::AcctName:select=true&Pooled_Sweep::F3::Master:select=true&Pooled_Sweep::F3::TransDate:select=true&Pooled_Sweep::F3::Description:select=true&Pooled_Sweep::F3::DailyTrans:select=true&Pooled_Sweep::F3::AvBal:select=true&Pooled_Sweep::F3::LedgBal:select=true&Pooled_Sweep::F3::YTDCont:select=true&Pooled_Sweep::F3::Rate:select=true&Pooled_Sweep::F3::Accrual:select=true""; " & chr$(10)

dhtmlCode = dhtmlCode & "alert(""Browser Code 2""); " & chr$(10)
dhtmlCode = dhtmlCode & "} " & chr$(10)
dhtmlCode = dhtmlCode & "} " & chr$(10)
dhtmlCode = dhtmlCode & "</SCRIPT> " & chr$(10)
dhtmlCode = dhtmlCode & "<A HREF=""#"" onClick=""detectBrowser()"">Export All</A> " & chr$(10)
dhtmlCode = dhtmlCode & "</FORM> "

End Sub

[/c]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top