0

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.

8
  • Why you are using Writeln() to create td element? Commented Mar 16, 2016 at 17:27
  • I'm doing code maintenance, and that is what was there already.Is there a better way? Commented Mar 16, 2016 at 17:30
  • The variable you want to pass is in the HTML document? Commented 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) Commented Mar 16, 2016 at 17:45
  • Ok, when you loop your array, where did you put TOPIC_ID ? Commented Mar 16, 2016 at 17:52

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Don't use < 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.