Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
160
rated 0 times [  162] [ 2]  / answers: 1 / hits: 15150  / 12 Years ago, wed, august 15, 2012, 12:00:00

I have a shopping cart checkout page and I'm trying to add a gift option. What needs to happen: Once the checkbox is selected for Send Order As Gift, a value needs to be assigned to a hidden input field so that the information is moved onto the confirmation page and various receipts.



HTML:



<h3>Send Order As Gift</h3>
<ul>
<li class=fc_row fc_gift><label for=gift class=fc_pre>This is a gift,
please do not include a receipt.</label>
<input type=checkbox name=gift id=gift class=checkbox value= />
<input type=hidden name=Gift id=gift-true value= /></li>
<script type=text/javascript>
$(document).ready(function(){
$(#gift-true).input( $('#edit-checkbox-id').is(':checked').val() + Yes);
});​
</script>
</li>
<li class=fc_row fc_gift_message><label for=Gift Message>Include a message
(limit 100 characters):</label>
<textarea name=Gift Message cols=50 rows=3 maxlength=100></textarea>
</li>
</ul>

More From » jquery

 Answers
7

You have to update your hidden field whenever the checkbox is changed:



$(function(){
$('#gift').change(function() {
$(#gift-true).val(($(this).is(':checked')) ? yes : no);
});
});

[#83615] Tuesday, August 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alysas

Total Points: 616
Total Questions: 111
Total Answers: 124

Location: Slovenia
Member since Wed, Apr 6, 2022
2 Years ago
alysas questions
Sun, Jul 19, 20, 00:00, 4 Years ago
Tue, Jun 23, 20, 00:00, 4 Years ago
Mon, Mar 30, 20, 00:00, 4 Years ago
;