Embedding radio buttons in a table and getting info from them

18 views
Skip to first unread message

Terry Gamel

unread,
May 30, 2019, 11:03:11 PM5/30/19
to Google Visualization API
I've got a google apps script page I've been putting together, and I'm using a chartwrapper for a table visualization. 

In my table visualization, I can, of course, put html.  I have a sheet where I've calculated how many radio buttons I need and built lines for them, something like this:

<input type="radio" name="96" value="1" checked="checked"><input type="radio" name="96" value="2"><input type="radio" name="96" value="3"><input type="radio" name="96" value="4"><input type="radio" name="96" value="5">
<input type="radio" name="97" value="1" checked="checked"><input type="radio" name="97" value="2"><input type="radio" name="97" value="3">
<input type="radio" name="98" value="1" checked="checked"><input type="radio" name="98" value="2"><input type="radio" name="98" value="3"><input type="radio" name="98" value="4">

And that displays perfectly in my table. 

The problem is figuring out how to get information back from those radio buttons.  I can't do a "getValue" on the cell because it's still just equal to the original html.  And I can't seem to respond to onclick events for them because they're inside the table, and the table's events are the only things that can be detected.

(If I build the same radio buttons outside the table, I can get the info just fine)

What other options do I have here to get that same kind of functionality?


Terry Gamel

unread,
May 31, 2019, 12:11:16 AM5/31/19
to Google Visualization API
I figured out something that works

I can add a form around my radio buttons with the event.preventdefault code and call a function:

<form name="myForm" onchange="event.preventDefault(); calcForm2(this);">...radiobuttons...</form>

Then in my function I do whatever I want with "this".  It comes across as "name=value" so it's pretty easy to split and parse.
Reply all
Reply to author
Forward
0 new messages