我试图有一个按钮链接生成一个特定的代码时单击表单字段,但似乎无法找到任何解决方案。我知道必须有一个Javacript答案,但没有任何建议的解决方案正在完成。有没有办法基于链接自动填充表单域?
表单代码:
<div class="nm-checkout-form-coupon">
<form class="checkout_coupon" method="post" style="display:none">
<p class="form-row">
<input type="text" id="coupon_code" name="coupon_code" class="input-text" placeholder="<?php _e('Physician Code', 'woocommerce'); ?>" id="coupon_code" value="" required />
</p>
<p class="for-row">
<p>Don't have a Physician Code? <a href="" data-toggle="modal" data-target="#physcode">Get one here!</a></p>
<!-- Physician Code Modal -->
<div class="modal fade access-code-popup" id="physcode" tabindex="-1" role="dialog" aria-labelledby="physcodelabel" >
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<p>AQ Skin Pro products are available exclusively through participating clinics and physicians offices. If you do not have an Exclusive Physician Code, click "generate a code" below.</p>
<button class="nm-simple-add-to-cart-button single_add_to_cart_button button alt" data-dismiss="modal" aria-label="Close" onClick="fillFields('coupon_code')" alutocomplete="off">Generate a Code</button>
</div>
</div>
</div>
</div>
</p>
<p class="form-row">
<input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Physician Code', 'woocommerce'); ?>" />
</p>
</form>
</div>
你可以你描述你想象的流程? 'apply_coupon'具有从php中粘贴的值,你在哪里试图访问它,它是如何失败的? –
与此处相同:https://venusskin.com/customer/account/create/ 在个人信息的左栏中,第一项是独家访问代码(如果您没有访问代码,请点击此处)。当你点击链接时,弹出的模式会在代码中生成代码并关闭。 – Cody
如果您查看该链接的源代码,您会在第481行找到相关的JavaScript代码 - 或搜索“代码提示”。 –