samedi 26 novembre 2016

JavaScript multiple checkboxes - delimited list - store and parse

Hey I was wondering if anybody can help

Im a newbie and dont know any  javascript ! I need help for my caspio app.

The code below works I just need to get the second part I got the first part of storing the values of checked checkboxes in a database field as a comma de-limited list.

Now I need to read the comma de-limited list from the database and update the checkboxes accordingly

THANK YOU !!!

<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{
var Resultfieldname = "CheckboxChoices";
var firstVirtual = 1;
var lastVirtual = 3;
var ResultString = "";
var virtualFieldName = "";

for (i=firstVirtual ;i<=lastVirtual; i++)
{
virtualFieldName = "cbParamVirtual"+i;
if (document.getElementById(virtualFieldName).checked) ResultString = ResultString + "," + document.getElementById(virtualFieldName).value;
}
Resultfieldname = "EditRecord"+Resultfieldname;
if (ResultString.length>0) ResultString = ResultString.substr(1);
document.getElementById(Resultfieldname ).value = ResultString;
}
document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT> 




Aucun commentaire:

Enregistrer un commentaire