0

Consider the following code:

while($row=mysql_fetch_assoc($result)){
                echo
                '<tr> ';
                echo    '<td><a href="#?id='.$row['id'].'" class="dep_link"><img src="images/icn_edit.png" title="Edit"></a>&nbsp;<a href="#"><img src="images/icn_trash.png" title="Trash"></a></td>';

In my php form, i have created a jquery dialog link such that when the user clicks the 'icn_edit.png' image , a new iframe is loaded with fields for update. i want to pass the 'id' variable from the link of that particular html table row to the division of html where the iframe is created so that i can use it as key for querying database. apparently, the iframe loads but the 'id' is not displayed in the test textfield.

how can i post the variable/value ie. the 'id'. the code works when i replace the '#' with an external file but not when i intend to pass it to a html div.

4
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by adam.adamski.96155
1

I'm a little confused as to what you're trying to do. Are you using the anchor link as a hyperlink (reload page / javascript hook) or are you using it as a bookmark (due to the #...)?

In order to pass info to the iframe, I'm assuming it needs to be via querystring like:

<iframe src="http://www.example.com?id=<?php echo $id;?>"></iframe>

If you've just got the one iframe, e.g. for a videoplayer, then js could be better for changing video srcs.

Edited by diafol

Votes + Comments
Nice Answer ! You beat me to it !
0

@mogaka

how can i post the variable/value ie. the 'id'. the code works when i replace the '#' with an external file but not when i intend to pass it to a html div.

To get the id you need to do this:

yourdomain/view.html?id=<?php echo $row['id'];?>

in your view.html there should be a query that select the id

Edited by LastMitch: grammer

0

Is this a JQuery issue? I noticed in JQuery mobile that pages are not truly loaded, and any GET vars are lost because the pages are loaded by ajax. Also this is a JQuery dialog that he is trying to pass the ID to I think.
It seems the OP already knows how to pass the variable in the URL : href="#?id='.$row['id'].'
Maybe it would be better to store the variable in a hidden input and access on the dialog page using Javascript?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.