I have a textbox on my html site that is named q. I want it that when people click on this link it will put the text of that link into the box.
This works:
<a href='#' onclick="javascript: document.getElementById('q').value = 'test';"><?php echo $firstName;?></a>
it puts the word test into the box named q
But this doesnt:
<a href='#' onclick="javascript: document.getElementById('q').value = '<?php echo $firstName;?>';"><?php echo $firstName;?></a>
Might anyone know why?
Thanks in advance
Rob
PHP and JS
Moderator: General Moderators
Re: PHP and JS
First name has quotes in it? Try this:
Code: Select all
<?php echo addslashes($firstName);?>Re: PHP and JS
firstname is just a string. I will be using it to hold ID numbers, it is usually something like a34234 or a12315 etckaszu wrote:First name has quotes in it? Try this:Code: Select all
<?php echo addslashes($firstName);?>
Re: PHP and JS
Then it should work.
Re: PHP and JS
This is a double post btw..
Here's the other: viewtopic.php?f=1&t=107512
Don't double post please. There are numerous reasons why it isn't allowed...read the forum rules for more info.
Here's the other: viewtopic.php?f=1&t=107512
Don't double post please. There are numerous reasons why it isn't allowed...read the forum rules for more info.