Php variable with javascript
Hello all,
Can anyone help?
I have a php variable with a value from a mySQl db. The value has to be passed to a submit button and also to a textfield. I have used javascript to do some of the work.
This creates the buttons using a loop with contents of db.
echo "<td ><input type='button' value='$servName' class='submit' onclick=fieldWrite('$servName')>";
On submit this JS bit fills a textfield with th users choice of button.
function fieldWrite(t)
{
with (document.Calc) {
textField.value = t;
}
}
However as some of the values have whitespace or apostrophes etc they are not working with js. Is there a way to use JS but reatain the whitespaces and punctuation marks?
Can anyone help?
I have a php variable with a value from a mySQl db. The value has to be passed to a submit button and also to a textfield. I have used javascript to do some of the work.
This creates the buttons using a loop with contents of db.
echo "<td ><input type='button' value='$servName' class='submit' onclick=fieldWrite('$servName')>";
On submit this JS bit fills a textfield with th users choice of button.
function fieldWrite(t)
{
with (document.Calc) {
textField.value = t;
}
}
However as some of the values have whitespace or apostrophes etc they are not working with js. Is there a way to use JS but reatain the whitespaces and punctuation marks?
Anthony T
February 27,