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

Button Value - HTA - Dynamic Table

Status
Not open for further replies.

country73

Technical User
Jan 17, 2003
59
0
0
US
Ok, I've created an HTA that will create a table dynamically from a text file.
The text file will create a list of buttons to display, and depending on which button is pressed, the SUB will preform a specific action. (Install application, Run application, etc...)
How do I pass the value of the button to my script so that I can set up a specific action for that item?

Portion that creates the table:
strAPP = "<table border=""1"" bordercolor=""#808080"" width=""100%""><tr><th>Updates</th></tr>"
IF oFS.FileExists(<path to txt file>)THEN
SET GFILE = oFS.GetFile(<path to txt file>)
SET RFILE = GFILE.OpenAsTextStream(1,-2)
DO UNTIL RFILE.AtEndOfStream
strApps = SPLIT(setDef.ReadLine,";")
strID = strApps(0)
strVal = strApps(1)
strNam = strApps(2)
strAPP = strAPP & "<tr><td><input id=" & strID & " type=""button"" name=""" & strNam & """ value=""" & strVal & """ onclick=""RunApp""></td></tr>"
LOOP
RFILE.Close
SET RFILE = NOTHING
SET GFILE = NOTHING
END IF
strAPP = strAPP & "</table>"
strHTML = strHTML & "<tr><td>" & strAPP & "</tr></td>"
TableArea.InnerHTML = strHTML

Portion of html for table:
<span id=TableArea>Enumerating Services, Please Wait</span></center>

Now, however many buttons are created (dependant of the text file), all of them will run a SUB called "RunAPP()".
How can I distinguish which button was actually clicked?

I've tried "id.value" and "name.value", but that doesn't work. Any ideas, or a better option for what I'm trying to do?
 
The way I would handle this would be something like this:

strAPP = strAPP & "<tr><td><input id=" & strID & " type=""button"" name=""" & strNam & """ value=""" & strVal & """ onclick=""RunApp('" & strVal & "')""></td></tr>"

Then change the sub to accept a parameter and work off of that.

Sub RunApp(strValue)
End Sub

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks for helping out on the little "brain-fart" I had going on; working like a charm now.

Nice to see you out and about on other forums; have you had any issues connecting to the other forum today?

I was out there earlier, but then I started getting all sorts of ASP errors when trying to connect...

Have to give it another shot later this afternoon.

Thanks again,
 
No problem. As for the other forum, I've been experiencing intermittent slowness, but it clears up after a while.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top