-1

I am working with a form that shows treatment history of a patient in a tabular format and it displays date,time,treatment amount. one td contains a view button.

<td align='left'  width='90px'><input type='button' class='btn_class' id=\"".$row['ipd_pat_trt_id']."\" value='view'/></td>

the view button contains treatment_id (field from treatment table) value as its id . Now what i want that when a user clicks on view button it should open a popup window and pass the treatment_id value to the popup window. And the popup window should display all the record from treatment table('select * from' is ok), based on the treatment_id value.
Any one can help me please.. Thanks in advance.

arshad
  • 21
  • 6

1 Answers1

0

A simple jQuery script would work, but you could just use a regular <form> post:

<table>
    <tr>
        <td>
            <button class="btn_class" id="300">View</button>
        </td>
    </tr>
</table>
<script>
// On click
$(".btn_class").click(function() {
        // Assign the button's id value
        var Id = $(this).attr('id');
        // Open a new window with a $_GET query into blank page
        window.open('?id='+Id,'_blank');
    });
</script>
Rasclatt
  • 12,249
  • 3
  • 21
  • 32
  • Thanks a lot. i got what i wanted and you didn't ask what i have tried so far :). Now if i have to do same thing using jquery model dialog, how to do it. See i have worked with jquery dialog but i don't know how to pass parameter to the dialog. thanks again. – arshad Dec 11 '14 at 06:00
  • Well, the id is passed in the query string so you get it on the pop up by using `$_GET['id']` in PHP. – Rasclatt Dec 11 '14 at 06:02
  • Incorrect. `id` cannot start with integers. See [this](http://stackoverflow.com/a/79022/188331) – Raptor Dec 11 '14 at 06:07
  • Does not work if requiring CSS styling...true. `HTML4` notes it in their guidelines as not kosher, however, `HTML5` does not seem to have a problem with it and it works in this scenario. If arshad wants to style said `id`s there in-lies a problem. This, however, does not appear to be the case. – Rasclatt Dec 11 '14 at 06:30