0
我正在创建一个网页,其中有两个div(帐单详细信息和送货详细信息)。加载页面后,系统会自动显示结算明细,并且运送详情为空。我已经包含了两个单选按钮,允许用户选择运送详情是否与结算明细相同。如果用户从单选按钮中选择“是”,则应在运送详情中显示相同的细节。 注:详细信息都存储在数据库中正在使用PHP来获得数据显示单击单选按钮时如何填充文本字段?
目前,我只用
<?php if(isset($_POST'[shipping'] == 'yes')){echo $fname} ?>
第一名称字段只是为了看它是否正在尝试,但我似乎没有工作。
<div id="leftprofile">
<form id="au" method="post" action="../../../coursework/coursework/scripts/checkout.php">
<fieldset class="billing">
<legend>Billing Details</legend><br />
<label for="fname" class="reglabel">First Name:</label>
<input required name="fname" type="text" id="fname" value="<?php echo $fname ?>"/><br />
<label for="lname" class="reglabel">Last Name:</label>
<input required name="lname" type="text" id="lname" value="<?php echo $lname ?>"/><br />
<label for="address" class="reglabel">Address:</label>
<input required name="address" id="address" type="text" value="<?php echo $address ?>"/><br />
<label for="town" class="reglabel">Town:</label>
<input required name="town" id="town" type="text" value="<?php echo $town ?>"/><br />
<label for="postcode" class="reglabel">Post Code:</label>
<input required name="postcode" id="postcode" type="text" value="<?php echo $postcode ?>"/><br />
<label for="phone" class="reglabel">Phone:</label>
<input required name="phone" id="phone" type="text" value="<?php echo $phone ?>"/><br />
<label for="email" id="EmailLabel" class="reglabel">E-mail:</label>
<input required name="email" type="email" id="email" value="<?php echo $email ?>"/><br />
</fieldset>
</form>
</div>
<div id="rightprofile">
<form id="au" method="post" action="../../../coursework/coursework/scripts/checkout.php">
<fieldset class="billing">
<legend>Shipping Details</legend><br />
<form>
Same as billing address?
<input type="radio" name="shipping" id="yes" value="yes">Yes
<input type="radio" name="shipping" id="no" value="no">No<br/>
</form>
<label for="fname" class="reglabel">First Name:</label>
<input required name="fname" type="text" id="fname" value="<?php if(isset($_POST'[shipping'] == 'yes')){echo $fname} ?>"/><br />
<label for="lname" class="reglabel">Last Name:</label>
<input required name="lname" type="text" id="lname" /><br />
<label for="address" class="reglabel">Address:</label>
<input required name="address" id="address" type="text" /><br />
<label for="town" class="reglabel">Town:</label>
<input required name="town" id="town" type="text" /><br />
<label for="postcode" class="reglabel">Post Code:</label>
<input required name="postcode" id="postcode" type="text" /><br />
<label for="phone" class="reglabel">Phone:</label>
<input required name="phone" id="phone" type="text" /><br />
<label for="email" id="EmailLabel" class="reglabel">E-mail:</label>
<input required name="email" type="email" id="email" /><br />
</fieldset>
</form>
</div>
那么,输入的名称既可以是结算和运输方式,也可以是相同的,所以当您最终获得提交的表单时,您会遇到问题。此外,这需要在Javascript中完成,因为它需要在表单提交之前处理。 (也应该注意,一次只能提交一个表单,现在你有两个单独的表单提交到同一个位置。) – Jon
他们是不同的div,但文本字段是相同的 – littledevils326
准确地说我的观点。如果所有提交到相同的“行动”,您需要区分开票和运输字段名称。 – Jon