在下面的代码中,我需要将firstname的值传递给hidden field(billing_name)。我已经尝试使用jquery和php。但它没有成功。
任何人都可以帮助我传递文本框的值,而无需将表单提交到隐藏字段
<form method="POST" name="customerData" action="<?php echo get_template_directory_uri(); ?>/payment/ccavRequestHandler.php">
<div id="personal-reservation-form-wrap">
<h5><?php echo $personalInfoHeader; ?></h5>
<div id="required-desc"><?php echo $personalInfoDescription; ?></div>
<div id="resform-firstname" class="form-field-wrap">
<div class="resform-header"><?php _e("Full Name","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="firstname" class="form-field-wrap required-field" id="firstname" required >
</div>
<div id="resform-lastname" class="form-field-wrap">
<div class="resform-header"><?php _e("Mobile Number","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="lastname" class="form-field-wrap required-field" required>
</div>
<div id="resform-email" class="form-field-wrap">
<div class="resform-header"><?php _e("Email","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="email" class="form-field-wrap required-field email-field" required>
</div>
<div id="resform-retypeyouremail" class="form-field-wrap">
<div class="resform-header"><?php _e("Address","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="resform-retypeyouremail" class="form-field-wrap required-field email-field" required>
</div>
<input type="hidden" name="order_id" value="<?php echo $tnx1 ?>"/>
<input type="hidden" name="merchant_id" value="555555"/>
<input type="hidden" name="amount" value="<?php echo $total_money; ?>"/>
<input type="hidden" name="checkin" value="<?php echo $checkin1; ?>"/>
<input type="hidden" name="checkout" value="<?php echo $checkout1; ?>"/>
<input type="hidden" name="roomid" value="<?php echo $room_id ?>"/>
<input type="hidden" name="currency" value="INR"/>
<input type="hidden" name="room_id" value="<?php echo $room_id; ?>" />
<input type="hidden" name="billing_name" value="">
<input type="hidden" name="billing_email" value="">
<input type="hidden" name="billing_tel" value="">
<input type="hidden" name="billing_address" value="">
<input type="hidden" name="redirect_url" value="http://hotels.com/wp-content/themes/wpnation/payment/ccavResponseHandler.php">
<input type="hidden" name="cancel_url" value="http://hotels.com/wp-content/themes/wpnation/payment/ccavResponseHandler.php"/>
<div id="resform-comments" class="form-field-wrap">
<div class="resform-header"><?php _e("Comments","nation") ?></div>
<textarea type="text" name="resform-comments" required></textarea>
</div>
<?php if ($enable_coupon) { ?>
<div id="resform-firstname" class="form-field-wrap">
<div class="resform-header"><?php _e("Enter Coupon Name","nation") ?></div>
<input type="text" name="resform-coupon" class="form-field-wrap">
</div>
<?php } ?>
<input name="room-id" type="hidden" value="<?php echo $_POST["room-id"]; ?>">
<input name="step3-send" type="hidden" value="true">
</div>
答案 0 :(得分:0)
如果提交后,您可以这样填写:
<input type="hidden" name="text_hidden" value="<?php echo htmlspecialchars($_POST['text_visible']); ?>">
如果在飞行中,那么使用jQuery:
<script>
$(document).ready(function () {
$('input[name="text_visible"]').on('change', function () {
$('input[name="text_hidden"]').val($('input[name="text_visible"]').val());
});
});
</script>
把它放在任何地方,我会在表格之前或之后推荐