I have this in a script of mine:
function add_option(section){
var sec = section.id;
var addnew = document.myform.addnew.value;
alert('add_option: section: '+addnew);
I am pulling text from the input with the name of addnew, and it works.
I would like to use a variable in place of the "addnew" line - Here is sample HTML:
<input type="text" name="addnew-cg" value="<?php echo date(U); ?>" placeholder="Add New Option" onKeyPress="return disableEnterKey(event,cg);" />
<input type="button" value="Add" onclick="add_option(cg);"><br />
So the form name is addnew-cg, or addnew-sectionname. In the JS I need to reference addnew-+sectionname.
Is that clear? How do I use a variable in the line:
var addnew = document.myform.addnew.value;
//does not work
var addnew = document.myform.addnew+"-"+sec.value;
//does not work
var addnew = document.myform."addnew-"+sec.value;
//does not work
var addnew = document.myform.addnew-+sec.value;
Thank you!