1
<?php foreach ($data['ACTION_DATA']['messages'] as $msg) { ?>
<form>
  <table>
   <tr><td>Name:</td><td id="name"><?php echo $msg['name']; ?> </td></tr>
   <tr><td>Telephone Number:</td><td id="tp"><?php echo $msg['tp_number']; ?></td></tr>
   <tr><td>ID:</td><td id="id"><?php echo $msg['id']; ?> </td></tr>
   <tr><td colspan="2"><input type="button" id="sub_button" onclick="show_popup()" value="View"></td></tr>
  </table>
</form>
<?php }; ?>

I used above code sample to display my page content. I want to get values according to instance block. and display them in popup window when click on the "View" button without re-load the page. pleace help me. thanks.

2
  • 1
    "I want to get values according to instance block." What do you mean exactly? Commented May 11, 2012 at 10:49
  • There will be a more than one tables in the page. I need one of these table value only. Commented May 11, 2012 at 10:53

2 Answers 2

2

I would add another input, with type hidden to hold the total number of entries. I would have each name, telephone and id inputs have different ids by adding an index number for each, something like:

<?php 
$index = 0
foreach ($data['ACTION_DATA']['messages'] as $msg) { ?>
<form>
  <table>
   <tr><td>Name:</td><td id="name<?php echo $index;?>"><?php echo $msg['name']; ?> </td></tr>
   ... same for the others ...
   <?php // increment index 
    $index++;
    ?>
   ....

And then use a for loop (you can get the total number of entries form the hidden input field) to browse through all the values.

If you want to only view one of them, send the index number as a parameter to the show_popup() method.

Sign up to request clarification or add additional context in comments.

Comments

0

can you use array.count function?

$total_tables = count($data['ACTION_DATA']['messages']);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.