generate js variable names on the fly
linked to yesterdays post...
showthread.php?t=3625
i have a form with several input fields created from a repeat region, namely price1, price2...etc
the number of fields displayed is dependent on how many sizes are available in the sizes recordset.
i want to apply spry validation to each of the input fields so that only numerical values can be input.
i know how many rows my sized recordset produces, so i can pass this into my js
what i want to do is generate the following on the fly, where * is a row number from the recordset
var sprytextfield* = new Spry.Widget.ValidationTextField("sprytextfield*", "currency", {isRequired:false});
i have the following loop which creates the correct information, but only as text string output, how do i get it to work ??...
<script type="text/javascript">
<!--
var totalsizes = <?php echo "'".$totalRows_rssizes."'"; ?>;//this is the number of rows in the sizes recordset, so this is how many sprytextfields we need
//-->
</script>
<script type="text/javascript">
<!--
var i=1;
for (i=1;i<=totalsizes;i++)
{
document.write("var sprytextfield" + i + " = new Spry.Widget.ValidationTextField('sprytextfield" + i +"', 'currency', {isRequired:false});");
document.write("<br />");
}
sorry, but my js isn't up to much, grateful for any advice