Posted on 2006-06-09
I would like to call eval on this function and pass that as the onclick script for a button.
The reason I am doing this is a bit har to explain , so I would like to find out if it is possible at all.
essentially I would like to have this:
1) <input type="button" value="Test" onclick="eval(popupTest('testing'))" />
But this doesn't work althought the following button works:
2) <input type="button" value="Test" onclick="eval(alert('testing'))" />
So I am assuming I need some quotes inside eval() in my first button example.
But when I tried calling it with double quotes., they were not being escaped although I had the escape character:
3)<input type="button" value="Test" onclick="eval(\"popupTest('testing')\")" />
Single quotes also did nothing.
It is essential that I use eval() . Can you offer any suggestions? And why are the double quotes not being escaped when inside eval? as in example 3?
Thanks in advance