Saleem Ahmed
Saleem Ahmed

Reputation: 260

How to pass variable content into modal

I need to pass variable to modal

The variable is

$row['content']

My modal

<button class="open-AddBookDialog btn btn-default" data-id='.$row['content'].' data-toggle="modal" >Edit</button>

Script

<script>
  $(document).on("click", ".open-AddBookDialog", function () {
  var myBookId = $(this).data('id');
  $(".modal-body #feature").val( myBookId );
  alert(myBookId);
  $('#myModal').modal('show');
  });
</script>  

I am getting the first words, No words shown which comes after space

Any experts??

Upvotes: 0

Views: 155

Answers (1)

Shahzad Barkati
Shahzad Barkati

Reputation: 2526

Just make little change: ( add " double quote before and after '.$row['content'].' as below: )

<button class="open-AddBookDialog btn btn-default" 
        data-id="'.$row['content'].'" data-toggle="modal" >
    Edit
</button>

Upvotes: 1

Related Questions