novice2004
Programmer
Help please.
Does anybody know if it is possible to send a string from php to JavaScript and then to concatenate it into object
because it does not work for me.
Gives me "Error on Page".
Thank you.
<FORM NAME="form" ID="form" ACTION="Layout.php" METHOD="post"
<input type="checkbox" name="title[]" value="1" />
<input type="checkbox" name="title[]" value="2" />
<input type="checkbox" name="title[]" value="3" />
$v1 = "form";
$v2 = "elements[\"title[]\"]";
print("<a href=\"javascript:document.form.submit()\" onClick=\"return validate(" . $v1 . "," . $v2 . ")\" >GO</a>");
function validate(v1,v2)
{
field = eval(v1 + "." + v2);
return ( validateCheckbox(field) );
}
function validateCheckbox(field)
{
for (i = 0; i < field.length; i++)
{ if(field.checked == true) return true; }
alert("Please select at least one checkbox.");
return false;
}
Does anybody know if it is possible to send a string from php to JavaScript and then to concatenate it into object
because it does not work for me.
Gives me "Error on Page".
Thank you.
<FORM NAME="form" ID="form" ACTION="Layout.php" METHOD="post"
<input type="checkbox" name="title[]" value="1" />
<input type="checkbox" name="title[]" value="2" />
<input type="checkbox" name="title[]" value="3" />
$v1 = "form";
$v2 = "elements[\"title[]\"]";
print("<a href=\"javascript:document.form.submit()\" onClick=\"return validate(" . $v1 . "," . $v2 . ")\" >GO</a>");
function validate(v1,v2)
{
field = eval(v1 + "." + v2);
return ( validateCheckbox(field) );
}
function validateCheckbox(field)
{
for (i = 0; i < field.length; i++)
{ if(field.checked == true) return true; }
alert("Please select at least one checkbox.");
return false;
}