sunny sunny - 2 years ago 91
Javascript Question

How to echo variables values in check box using pop up?

I am new in PHP. I have a code having a button. When button is clicked a modal will show. On modal, there are multiple check-boxes. When one of the check-boxes is checked, a value of that check-box should print. But I want to print that values in check-boxes on the modal.

Please Check This Fiddle

Here is my code

.ready(function() {
maxWidth: 800,
maxHeight: 600,
fitToView: false,
width: '70%',
height: '70%',
autoSize: false,
closeClick: false,
openEffect: 'none',
closeEffect: 'none'

$('.button1').click(function(e) {

.on('change', '[name=test-link]', function() {
$('#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=""></script>
<link href="" rel="stylesheet"/>
<script src=""></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" />
<br />
<input type='checkbox' name='test-link' value="2" />
<br />
<input type='checkbox' name='test-link' value="3" />
<br />

Answer Source

Append input and use the value in value attribute of input

$('#print-values').append("<input type=text value='"+v+"'><br />");


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download