Reputation: 1593
I am new in PHP. I have two files. file_upload.php
and test1.php
i have a button on file_upload.php
<input type="button" value="Link More Opinion" onclick="popUp('test1.php');" />
JavaScript of that Button
<script type="text/javascript">
function popUp(url) {
window.open(url,'PHP Pop Up','width=500,height=500');
}
</script>
When i click on Button test1.php
file is open in Pop Up window contain checkbox
Here is code
<?php
include "connection.php";
$sql= "SELECT * FROM `og_companies` ORDER BY name";
$result = mysql_query($sql) ;
while($row = mysql_fetch_array($result))
{
$all_opinions[] = $row['name'];
}
$all_opinions_implode = implode(",", $all_opinions);
$all_opinions_explode = explode (",", $all_opinions_implode);
?>
<form action="file_upload.php" id="form" method="post" name="form">
<?php
for ($i=0; $i<count($all_opinions_explode); $i++) {
echo "<input type='checkbox' name='test_link' > $all_opinions_explode[$i]";
//echo ;
echo'</br>';
}
?>
<input type="submit" name="submit" id="submit" value="submit"/>
Now i want to get Value of Checkbox on file_upload.php
but i fail. Can anyone please help me?
Upvotes: 1
Views: 119
Reputation: 402
you can solve your problem by using fancybox to open inline element!
I put both of your pages in one file and then I use fancy box to open #form1 element when you click on the button.
then you can check the checkboxes and see the result;
checked values printed to #print-values div element.
$(document)
.ready(function() {
$(".various").fancybox({
maxWidth: 800,
maxHeight: 600,
fitToView: false,
width: '70%',
height: '70%',
autoSize: false,
closeClick: false,
openEffect: 'none',
closeEffect: 'none'
});
$('.button1').click(function(e) {
e.preventDefault();
$('.various').click();
});
})
.on('change', '[name=test-link]', function() {
$('#print-values').empty();
$('#print-values').append("<span>You've checked:</span><br />");
$('[name=test-link]').each(function() {
if ($(this).prop("checked")) {
var v = $(this).val();
$('#print-values').append(v + "<br />");
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
<a class="various" href="#form1" style='display: none;'></a>
<input class='button1' type="button" value="Link More Opinion" />
<div id='print-values'></div>
<div style='display: none;'>
<form id='form1'>
<input type='checkbox' name='test-link' value="1" />
<span>1</span>
<br />
<input type='checkbox' name='test-link' value="2" />
<span>2</span>
<br />
<input type='checkbox' name='test-link' value="3" />
<span>3</span>
<br />
</form>
</div>
Upvotes: 1