0

Is it possible to pass a variable from anattribute to a modal. I need to use the value of the variable to return data from a*.php` function.enter code here

The call to the Modal with the record value in the data-id attribute.

<a href='#openModal' value='Edit' data-id=".$events['evnt_id'].">Edit</a>;

This will be Modal that will be displayed.

<div id="openModal" class="modalDialog">
    <div>
        <a href="#close" title="Close" class="close">X</a>
        <table border="1" width="600" height="500" cellpadding="5" cellspacing="0">
        <tr>
            <td>
                $detail = Stuff->getDetails($_GET['data-id']);

            </td>
        </tr>
        </table>
    </div>
</div>

1 Answer 1

1

if you want access data-id you can use javascript / jquery to do that.

my suggestion is :

1. change the link to this :

<a href='#' id="myModal" value='Edit' data-id=".$events['evnt_id'].">Edit</a>

2. in modal :

<tr>
  <td id="place-data-id">
  </td>
</tr>

3. in javascript access data id like this :

<script type="text/javascript">
$("#myModal").click(function(){
  var myDataId = $(this).data('id'); // get data-id
  $("#place-data-id").html(myDataId); // insert data id to td
  $("#openModal").modal('show'); // showing modal
});
</script>
Sign up to request clarification or add additional context in comments.

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.