hello. I'm using Ubuntu and Mozilla. I have a button in a php script which calls a javascript function displaying an alert box with text passed as a parameter.
echo "<input type='button' ondblclick=confirm(".$txt.");>";
I've tried all sorts of variations confirm'"(.txt."'), javascript confirm( etc.
If the $txt="Hello", it works fine. If $txt="Hello world" the alert box doesn't appear at all.
Thanks
Tony
spaces in text to alert box
Moderator: General Moderators
- lukewilkins
- Forum Commoner
- Posts: 55
- Joined: Tue Aug 12, 2008 2:42 pm
Re: spaces in text to alert box
Try this:
Do you really want ondblclick for a button? Why not onclick?
Hope that helps!
Code: Select all
<?php
$txt = 'Hello World!';
echo '<input type="button" value="YourButton" ondblclick="confirm(\'' . $txt . '\');"';
?>Hope that helps!
Re: spaces in text to alert box
No. This is a test for something else which exhibits the same problem.
Tony
Tony
- lukewilkins
- Forum Commoner
- Posts: 55
- Joined: Tue Aug 12, 2008 2:42 pm
Re: spaces in text to alert box
Uhhm, no, actually it works perfectly. The message board however is not displaying it correctly.
Just replace [BACKSLASH] with an actual backslash and test. ... It works ... you need single quotes around your phrase in your confirm dialogue but therefore you also need to escape them.
Just replace [BACKSLASH] with an actual backslash and test. ... It works ... you need single quotes around your phrase in your confirm dialogue but therefore you also need to escape them.
Code: Select all
<?php
$txt = 'Hello World!';
echo '<input type="button" value="YourButton" ondblclick="confirm([BACKSLASH]'' . $txt . '[BACKSLASH]');"';
?>Re: spaces in text to alert box
Works now. Thanks very much
Tony
Tony
- lukewilkins
- Forum Commoner
- Posts: 55
- Joined: Tue Aug 12, 2008 2:42 pm
Re: spaces in text to alert box
No problem, glad I could help!
Luke
Luke