The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Help with passing data using Modal - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: Help with passing data using Modal (/showthread.php?tid=693)



Help with passing data using Modal - muhammedc - 08-27-2017

Hi guys...

So wondering if any of you have any experience using modal... So what I am trying to achieve, is to display a grid of data and a button next to each row which when a user clicks will popup a modal and ask for an email address. Then take that email address and submit it to another php file to generate pdf document and email that address. The problem I am having is the variable passed to the modal post command is that last row and not the row of the actual line where the button is...

here is some code:

<table class="table table-hover">
<thead>
<tr>
<th>Id</th>
<th>File#</th>
<th>Subject</th>
<th>Author</th>
<th>Date Created</th>
<th>Last Edited By</th>
<th>Date Last Edited</th>
<th>PDF</th>
</tr>
</thead>
<tbody>
<tr>
<?php foreach ($filenumberResult as $FNR) { ?>
<td><?=$FNR->ID?></td>
<td><a>ID?>"><?=$FNR->FILENUMBER?></a></td>
<td><a>ID?>"><?=$FNR->SUBJECT?></a></td>
<td><?php echouser ($FNR->AUTHOR);?></td>
<td><?=$FNR->DATECREATED?></td>
<td><?php echouser ($FNR->LASTEDITEDBY);?></td>
<td><?=$FNR->DATELASTEDITED?></td>
<td><a>ID?>&fn=<?=$FNR->FILENUMBER?>&dov=D&webkey=<?=$FNR->WEBKEY?>&subject=<?=$FNR->SUBJECT?>"><i class="fa fa-fw fa-file-pdf-o"></i></a> | <a>ID?>&fn=<?=$FNR->FILENUMBER?>&dov=I&webkey=<?=$FNR->WEBKEY?>" target="_blank"><i class="fa fa-fw fa-eye"></i></a> | ID?>"><i class="glyphicon glyphicon-envelope"></i></td>
</tr>
<?php } ?>
</tbody>

<!-- Trigger the modal with a button -->

<!-- Modal -->
<div class="modal fade" id="email-letter" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" action="emailpdf.php?id=<?=$FNR->ID?>&fn=<?=$FNR->FILENUMBER?>&dov=S&webkey=<?=$FNR->WEBKEY?>&subject=<?=$FNR->SUBJECT?>" method="post">
<div class="modal-header"><h4>Email Letter...</h4></div>
<div class="modal-body">

<div class="form-group">
<?php dump($FNR->ID);?>
<label for="contact-email" class="col-lg-2 control-label">E-mail:</label>
<div class="col-lg-10">
<input type="email" class="form-control" name="contact-email" id="contact-email" placeholder="you@example.com" required><br>
</div>
</div>

</div>
<div class="modal-footer">
<button class="btn btn-success" type="submit">Send Message</button>
<a>Cancel</a>
</div>
</form>
</div>
</div>
</div>

The line:

form class="form-horizontal" action="emailpdf.php?id=<?=$FNR->ID?>&fn=<?=$FNR->FILENUMBER?>&dov=S&webkey=<?=$FNR->WEBKEY?>&subject=<?=$FNR->SUBJECT?>" method="post">

is always getting the last row data and not the row it is assigned to.

I need to figure out how to pass the actual row variables in the action="emailpdf.php?id= protion but am stumped.

I hope im making sense... Any ideas or help cos i have searched and cant seem to figure this out.

Thanks -M


Help with passing data using Modal - muhammedc - 08-27-2017

ok - i think i may have found a solution using the information from :

https://w3heap.com/questions/2522/pass-php-variable-to-bootstrap-modal

Going to test now... fingers crossed


Help with passing data using Modal - mudmin - 08-27-2017

Good luck Smile



Help with passing data using Modal - karsen - 08-27-2017

Let me know if you don't get it to work, I'm currently working on something similar with modals and can help figure out your problem if needed.