Re: problem with many buttons [message #182812 is a reply to message #182810] |
Mon, 16 September 2013 13:41 ![Go to previous message Go to previous message](/forum/theme/default/images/up.png) |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
Fiver wrote:
> On 2013-09-16 08:25, Avnesh Shakya wrote:
>> <?php
>> echo "<script type='text/javascript'>function blogId($bgid) {
>> top.location.href = './blogComment.php?id=$bgid'; };</script>";
>> ?>
>>
>> it is going on that page but not contaid this value...
>
> echo "... $bgid ..." will try to interpolate the PHP variable "$bgid"
> into the string. Depending on your settings and whether $bgid actually
> exists, this will result in an error or something you didn't want.
> JavaScript variables and function arguments are not usually prefixed
> with a "$" sign. Try this instead (without the <?php ... ?> around it):
>
> <script type="text/javascript">
> function blogId(bgid) {
> top.location.href = './blogComment.php?id=' + bgid;
> }
> </script>
I am afraid that this code is not going to work until someone with a minimum
clue will be rewriting it. For example,
| echo "<li><button id=$bgname onclick = return(blogId($this))>".
| $row['blogs_name']."</button></li>";
is not going to work already because “$this” will be expanded to "" while
generating the notice “Undefined variable: this”. It must be “this”
instead, and the “onclick“ attribute value must be quoted; but to know that
you have to have at least a basic understanding of HTML, and you have to
know the difference between server-side and client-side code, and between
PHP (used here server-side) and ECMAScript/JavaScript (used here client-
side).
PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
|
|
|