I am attempting to populate a button dynamically using VBScript and call a JavaScript function from it passing a parameter (I'd like to pass 2). Here's what I have:
WriteLn ("<td nowrap class=""ContentActionSmall"">
<input type='button' name='VeiwReport' value='VIEW REPORT'
onclick='jsfunction()'> </td>"
This is a static call to the jsfunction:
function jsfunction(lnk)
{
alert("fx called V0.4 "+lnk);
go_pop_upA("/aa/rpt/detailedReport_go.asp");
}
This part also works. But it is static. I need to pass a variable inside the onclick='jsfunction() like this:
WriteLn ("<td nowrap class=""ContentActionSmall"">
<input type='button' name='VeiwReport' value='VIEW REPORT'
onclick='jsfunction(TOPIC_ID)'> </td>"
When I do this, jsfunction does not execute.
I've tried a number of things, including calling a VBScript Function or sub with the VB functions and subs not executing (calling jsfunction)
The goal is to open another page with the TOPID_ID and another string passed to the new page, which will be a popup window the user can close. So the above code, which was mostly in place when I started, does not have to remain the same.
-
Why you are using Writeln() to create td element?Jorge Mejia– Jorge Mejia2016年03月16日 17:27:47 +00:00Commented Mar 16, 2016 at 17:27
-
I'm doing code maintenance, and that is what was there already.Is there a better way?Potemkyn– Potemkyn2016年03月16日 17:30:11 +00:00Commented Mar 16, 2016 at 17:30
-
The variable you want to pass is in the HTML document?Jorge Mejia– Jorge Mejia2016年03月16日 17:34:20 +00:00Commented Mar 16, 2016 at 17:34
-
It comes from a table: For intI = 0 To UBound(arrData,2) Course_ID = arrData(0,intI) Course_Name = arrData(1,intI) TOPIC_ID = arrData(2,intI)Potemkyn– Potemkyn2016年03月16日 17:45:11 +00:00Commented Mar 16, 2016 at 17:45
-
Ok, when you loop your array, where did you put TOPIC_ID ?Jorge Mejia– Jorge Mejia2016年03月16日 17:52:47 +00:00Commented Mar 16, 2016 at 17:52
1 Answer 1
Okay, this was... too complex a way to approach this. So I ditched the input/button and went back to this:
Response.Write("<td nowrap class=""ContentActionSmall"">
<a href=""javascript:go_pop_up('/aa/rpt/detailedReport_go.asp?
TOPIC_ID="& TOPIC_ID &"')"">View Report</a>")
This worked.
2 Comments
< a href="javascript:...">...</a> it's doesn't degrade nicely! See Href attribute for JavaScript links: "#" or "javascript:void(0)"?, it's a throwback from an earlier time and shouldn't be anywhere in modern code.