i wanted to display another tag value inside an onclick return confirm message that also contained php code, so it was a challenge to figure out how to escape all the single quote and double quotes variables. this one gave me a run for my money, but here's the example code that finally works:
...
<input type="text" name="newString">
<button type="submit" onclick="return confirm('Change [ <?= $this->oldString ?> ] to [ '+document.getElementsByName('newString')[0].value+' ]?')">change string</button>
...
No comments:
Post a Comment