I have used Aheadworks_OneStepCheckout
and I added some checkbox.
However, I can't get the value of the checkbox. My code:
/** * Copyright 2019 aheadWorks. All rights reserved. * See LICENSE.txt for license details. */ define( [ 'uiComponent', 'Aheadworks_OneStepCheckout/js/model/checkout-data', 'Aheadworks_OneStepCheckout/js/model/order-note/contact-type' ], function (Component, checkoutData, contactType) { 'use strict'; return Component.extend({ defaults: { template: 'Aheadworks_OneStepCheckout/sidebar/contact-type', inputValue: '' }, isVisible: true, /** * @inheritdoc */ initialize: function () { var contactType = checkoutData.getContactType(); console.log('====='+ contactType); this._super(); if (contactType) { this.inputValue(contactType); } this.inputValue.subscribe(function (newValue) { checkoutData.setContactType(newValue); }, this); }, /** * @inheritdoc */ initObservable: function () { this._super(); this.inputValue = contactType; return this; }, contactPhone : function () { console.log(this.checked); console.log(this.val()); return data.val(); }, }); } );
Template:
<div class="aw-sidebar_contact-type" data-bind="visible: isVisible">
<span data-role="title" class="toggle" data-bind="i18n:'Contacts'"></span>
<div class="content" data-role="content">
<input data-role="contact-type-input"
data-bind="value: inputValue" id="contacttype" type="textbox" value="1" class="checkbox"> <label></label>
<div class="contact">
<div class="aw-onestepcheckout-general-form-field">
<div class="control">
<input data-bind="value: contactPhone, click: function(){jQuery('#contacttype').val}" type="checkbox" id="contact[phone]" name="contact_phone" value="1" class="checkbox"> <label></label>
</div>
<label for="contact[phone]" data-bind="click: onSubmit" style="width:85%">1.Call or Text My Cell Phone</label>
<div style="clear:both;"></div>
</div>
<div class="aw-onestepcheckout-general-form-field">
<div class="control">
<input type="checkbox" id="contact[local]" name="contact_local" value="1" class="checkbox"> <label></label>
</div>
<label for="contact[local]" data-bind="click: onSubmit" style="width:85%">2.I will call you from a local land line when i check in and provide you with my information</label>
<div style="clear:both;"></div>
</div>
<div class="aw-onestepcheckout-general-form-field">
<div class="control">
<input type="checkbox" id="contact[whassap]" name="contact_whassap" value="1" class="checkbox"> <label></label>
</div>
<label for="contact[whassap]" data-bind="click: onSubmit" style="width:85%">3.Contact me via whats app</label>
<div style="clear:both;"></div>
</div>
<div class="aw-onestepcheckout-general-form-field">
<div class="control">
<input type="checkbox" id="contact[caretaker]" name="contact_caretaker" value="1" class="checkbox"> <label></label>
</div>
<label for="contact[caretaker]" data-bind="click: onSubmit" style="width:85%">4.Contact the concerige/Properity Caretaker </label>
<div style="clear:both;"></div>
</div>
<div class="aw-onestepcheckout-general-form-field">
<div class="control">
<input type="checkbox" id="contact[room]" name="contact_room" value="1" class="checkbox"> <label></label>
</div>
<label for="contact[room]" data-bind="click: onSubmit" style="width:85%">5.I have provied my room number - Call My Room"</label>
<div style="clear:both;"></div>
</div>
</div>
</div>
</div>
Expect: when I checkbox in the list. All value will push to textbox id contacttype