如何使用php在下一页上保留用户选中的单选按钮?

时间:2011-05-04 19:42:44

标签: php html

我正在尝试保留已由用户选择的已检查单选按钮以传递到同一页面,但是要确认允许用户查看他们输入的内容是否正确。这不应该是这么难,但我不能让它做得很好。

现在它正在进行一次检查,但它只是最后一次,并没有影响用户选择。

谢谢!

编辑:

我想我的代码现在搞砸了。我尝试添加会话数组,但现在我的验证页面没有加载。我喜欢用会话数组设置它的想法,因为我正在考虑将这些数据传递到电子邮件中,一旦验证它。这是我现在两页的代码。

order_form.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HMC Promotional Items</title>
<link href="css/hmcpromo_secure.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationRadio.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" />

<?php

session_start();

?>

</head>

<body>

<div id="logo"><img src="images/wfhm_bw_logo.jpg" width="272" height="114" /></div>

<div>
<h1>HMC Web Sites</h1>
<h2>Personalized Promotional Items</h2>
<br />
<p>
  The cost of items ordered will be deducted from branch P&amp;L. If this is a personal order, complete credit card information below. <strong>Order form must be filled out completely.</strong> If you do not receive an email acknowledgment of your order within 2 business days, please call 1-800-535-1395 to verify receipt.</p>
</div>


<form id="promo_order_form" name="promo_order_form" method="post" action="verify_order_form.php">

<div id="order_form">
<span id="sprytextfield7">
<label for="Order_Date">Order Date:</label>
    <input type="text" name="Order_Date" id="Order_Date" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield17">
    <label for="Date_Needed">Date Needed:</label>
    <input type="text" name="Date_Needed" id="Date_Needed" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield16">
    <label for="AU">AU #:</label>
    <input type="text" name="AU" id="AU" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    (Required for ALL orders, including credit card orders)
    <br />
    <br />
<span id="sprytextfield15">
    <label for="Approved">Approved by:</label>
    <input type="text" name="Approved" id="Approved" />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    (Managers approval required)
    <br />
    <br />
<span id="sprytextfield5">
    <label for="mgrEmail">Manager Email:</label>
    <input type="text" name="mgrEmail" id="mgrEmail" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield14">
    <label for="Contact">Contact:</label>
    <input type="text" name="Contact" id="Contact" />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
<span id="sprytextfield13">
    <label for="Email">Email:</label>
    <input type="text" name="Email" id="Email" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield12">
    <label for="Phone1">Phone #:</label>
    <input type="text" name="Phone1" id="Phone1" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield8">
<label for="Fax">Fax #:</label>
<input type="text" name="Fax" id="Fax" />
<span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
<span id="sprytextfield9">
<label for="MAC">MAC #:</label>
<input type="text" name="MAC" id="MAC" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield10">
    <label for="Ship">Ship to:</label>
    <input type="text" name="Ship" id="Ship" />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
<span id="sprytextfield11">
    <label for="Attention">Attention:</label>
    <input type="text" name="Attention" id="Attention" />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
</div>

<div id="personal_form">
  <div id="personal_header">PERSONAL ORDERS ONLY:</div>

  <span id="spryradio1">
  <label>
    <input type="hidden" name="Visa" value="">
    <input name="cc" type="radio" id="Visa" value="Visa"/>
    Visa</label>
  <br />
  <label>
    <input type="hidden" name="Master" value="">
    <input type="radio" name="cc" value="Master" id="Master" />
    Mastercard</label>
  <br />
  <label>
    <input type="hidden" name="Amex" value="">
    <input type="radio" name="cc" value="Amex" id="Amex" />
    Amex</label>
</span>

  <span id="sprytextfield21">
  <label for="CardNum">Card Number:</label>
  <input type="text" name="CardNum" id="CardNum" />
  <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
  <br />
  <br />

  <span id="sprytextfield18">
  <label for="exp">EXP:</label>
  <input name="exp" type="text" id="exp" value="MM/YY" size="10" maxlength="5" />
</span>

  <span id="sprytextfield20">
  <label for="cvs">CVS #:</label>
  <input name="cvs" type="text" id="cvs" size="5" maxlength="3" />
  <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
  <br />
  <br />
  <span id="sprytextfield19">
  <label for="auth">Name on Card:</label>
  <input name="auth" type="text" id="auth" size="40" />
</span>
</div>

<div id="delivery">
    <p>Please allow 3 weeks for delivery.
    <br />
    <br />
    Orders will ship via UPS Ground. Individual product styles will ship separately.
  </p>
</div>

    <br />
<ul>
  <li class="clear">PERSONALIZATION INFORMATION</li>
</ul>

<div id="pers_form">
<span id="sprytextfield3">
    <label for="First">First Name:</label>
    <input type="text" name="First" id="First" />
    <span class="textfieldRequiredMsg">A value is required.</span></span>

<span id="sprytextfield2">
    <label for="Last">Last Name:</label>
    <input type="text" name="Last" id="Last" />
    <span class="textfieldRequiredMsg">A value is required.</span></span><br /><br />

<span id="sprytextfield4">
    <label for="Phone2">Phone #:</label>
    <input type="text" name="Phone2" id="Phone2" />
    <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>

<span id="sprytextfield1">
    <label for="Email2">Email:</label>
    <input type="text" name="Email2" id="Email2" />
    <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
</div>

<div id="totals_header">
TOTAL COST
</div>

    <br />
<ul>
  <li>ITEM</li>
</ul>

<div id="item_form">
  <h3>Executive Metal Grip Roller</h3>
    <input name="ItemNum" type="hidden" id="ItemNum" value="EMGR" />
    <br />
    <input name="ItemPrice" type="text" id="ItemPrice" value="$1.10 Each" size="12" readonly="readonly" />
    <br />
    <br />
<span id="sprytextfield6">
<label for="Qty">Qty (Minimum 300):</label>
<input name="Qty" type="text" id="Qty" size="10" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldMinValueMsg">The entered value is less than the minimum required.</span></span><br />
    <br />
    <label for="Total">Total:</label>
    <input name="Total" type="text" id="Total" size="25" readonly="readonly" />
    <br />
    <hr />
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    <br />
</div>

<div id="totals_form">
  <label for="Subtotal">Subtotal</label>
  <input name="Subtotal" type="text" id="Subtotal" size="15" readonly="readonly" />
  <br />
  <br />
  <label for="Sales_Tax">Sales Tax (MN only)</label>
  <input name="Sales_Tax" type="text" id="Sales_Tax" size="15" />
  <br />
  <br />
  <label for="P_H">Packaging and Handling</label>
  <input name="P_H" type="text" id="P_H" value="$3.75" size="15" readonly="readonly" />
  <br />
  <br />  
  <label for="Freight">Freight</label>
  <input name="Freight" type="text" id="Freight" size="15" readonly="readonly" />
  <br />
  <hr />
  <label for="Totals">Total</label>
  <input name="Totals" type="text" id="Totals" size="15" readonly="readonly" />
</div>

<div class="clear"><!--CLEAR--></div>

</form>

<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {isRequired:false});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "phone_number", {isRequired:false, useCharacterMasking:true});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "email", {useCharacterMasking:true});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "integer", {minValue:300});
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "date", {useCharacterMasking:true});
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "phone_number", {useCharacterMasking:true});
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9", "integer", {useCharacterMasking:true});
var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "none");
var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11", "none");
var sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12", "phone_number", {useCharacterMasking:true});
var sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13", "email", {useCharacterMasking:true});
var sprytextfield14 = new Spry.Widget.ValidationTextField("sprytextfield14");
var sprytextfield15 = new Spry.Widget.ValidationTextField("sprytextfield15");
var sprytextfield16 = new Spry.Widget.ValidationTextField("sprytextfield16", "integer");
var sprytextfield17 = new Spry.Widget.ValidationTextField("sprytextfield17", "date", {useCharacterMasking:true});
var spryradio1 = new Spry.Widget.ValidationRadio("spryradio1", {isRequired:false});
var sprytextfield18 = new Spry.Widget.ValidationTextField("sprytextfield18", "none", {isRequired:false});
var sprytextfield19 = new Spry.Widget.ValidationTextField("sprytextfield19", "none", {isRequired:false});
var sprytextfield20 = new Spry.Widget.ValidationTextField("sprytextfield20", "integer", {isRequired:false});
var sprytextfield21 = new Spry.Widget.ValidationTextField("sprytextfield21", "integer", {isRequired:false});
//-->
</script>
</body>
</html>

verify_order_form.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HMC Promotional Items</title>
<link href="css/hmcpromo_secure.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationRadio.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" />

<?php

session_start();

$_SESSION['Visa'];
$_SESSION['Master'];
$_SESSION['Amex'];



//Order Form Var
$Order_Date = strip_tags($_POST['Order_Date']);
$Date_Needed = strip_tags($_POST['Date_Needed']);
$AU = strip_tags($_POST['AU']);
$Approved = strip_tags($_POST['Approved']);
$mgrEmail = strip_tags($_POST['mgrEmail']);
$Contact = strip_tags($_POST['Contact']);
$Email = strip_tags($_POST['Email']);
$Phone1 = strip_tags($_POST['Phone1']);
$Fax = strip_tags($_POST['Fax']);
$MAC = strip_tags($_POST['MAC']);
$Ship = strip_tags($_POST['Ship']);
$Attention = strip_tags($_POST['Attention']);

//Personal Order Form Var
//$Visa = strip_tags($_POST['Visa']);
//$Master = strip_tags($_POST['Master']);
//$Amex = strip_tags($_POST['Amex']);
$CardNum = strip_tags($_POST['CardNum']);
$exp = strip_tags($_POST['exp']);
$cvs = strip_tags($_POST['cvs']);
$auth = strip_tags($_POST['auth']);

//Personalization Form Var
$First = strip_tags($_POST['First']);
$Last = strip_tags($_POST['Last']);
$Phone2 = strip_tags($_POST['Phone2']);
$Email2 = strip_tags($_POST['Email2']);

//Item Form Var and Math
$ItemNum = strip_tags($_POST['ItemNum']);
$ItemPrice = strip_tags($_POST['ItemPrice']);
$ItemNum = strip_tags($_POST['ItemNum']);
$Qty = strip_tags($_POST['Qty']);
$Total = strip_tags($_POST['Total']);

//Totals Form Math
$Subtotal = strip_tags($_POST['Subtotal']);
$Sales_Tax = strip_tags($_POST['Sales_Tax']);
$P_H = strip_tags($_POST['P_H']);
$Freight = strip_tags($_POST['Freight']);
$Totals = strip_tags($_POST['Totals']);

?> 

</head>

<body>

<div id="logo"><img src="images/wfhm_bw_logo.jpg" width="272" height="114" /></div>

<div>
<h1>Executive Metal Grip Roller</h1>
<h2>Personalized Promotional Items</h2>
<br />
<p>
  The cost of items ordered will be deducted from branch P&amp;L. If this is a personal order, complete credit card information below. <strong>Order form must be filled out completely.</strong> If you do not receive an email acknowledgment of your order within 2 business days, please call 1-800-535-1395 to verify receipt.</p>
</div>

<form id="promo_order_form" name="promo_order_form" method="post" action="">

<div id="order_form">
<span id="sprytextfield7">
<label for="Order_Date">Order Date:</label>
    <input type="text" name="Order_Date" id="Order_Date" value='<?php echo htmlentities($Order_Date) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield17">
    <label for="Date_Needed">Date Needed:</label>
    <input type="text" name="Date_Needed" id="Date_Needed" value='<?php echo htmlentities($Date_Needed) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield16">
    <label for="AU">AU #:</label>
    <input type="text" name="AU" id="AU" value='<?php echo htmlentities($AU) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    (Required for ALL orders, including credit card orders)
    <br />
    <br />
<span id="sprytextfield15">
    <label for="Approved">Approved by:</label>
    <input type="text" name="Approved" id="Approved" value='<?php echo htmlentities($Approved) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    (Managers approval required)
    <br />
    <br />
<span id="sprytextfield5">
    <label for="mgrEmail">Manager Email:</label>
    <input type="text" name="mgrEmail" id="mgrEmail" value='<?php echo htmlentities($mgrEmail) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield14">
    <label for="Contact">Contact:</label>
    <input type="text" name="Contact" id="Contact" value='<?php echo htmlentities($Contact) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
<span id="sprytextfield13">
    <label for="Email">Email:</label>
    <input type="text" name="Email" id="Email" value='<?php echo htmlentities($Email) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield12">
    <label for="Phone1">Phone #:</label>
    <input type="text" name="Phone1" id="Phone1" value='<?php echo htmlentities($Phone1) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield8">
<label for="Fax">Fax #:</label>
<input type="text" name="Fax" id="Fax" value='<?php echo htmlentities($Fax) ?>' />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
    <br />
    <br />
<span id="sprytextfield9">
    <label for="MAC">MAC #:</label>
    <input type="text" name="MAC" id="MAC" value='<?php echo htmlentities($MAC) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
<span id="sprytextfield10">
    <label for="Ship">Ship to:</label>
    <input type="text" name="Ship" id="Ship" value='<?php echo htmlentities($Ship) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
<span id="sprytextfield11">
    <label for="Attention">Attention:</label>
    <input type="text" name="Attention" id="Attention" value='<?php echo htmlentities($Attention) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span></span>
    <br />
    <br />
</div>

<div id="personal_form">
  <div id="personal_header">PERSONAL ORDERS ONLY:</div>

  <span id="spryradio1">
  <label>
    <input type="radio" name="cc" value="Visa" <?php echo if($_SESSION['cc'] == "Visa"){'checked="checked"';} ?> id="Visa"  />
    Visa</label>
  <br />
  <label>
    <input type="radio" name="cc" value="Master" <?php echo if($_SESSION['cc'] == "Master"){'checked="checked"';} ?> id="Master" />
    Mastercard</label>
  <br />
  <label>
    <input type="radio" name="cc" value="Amex" <?php echo if($_SESSION['cc'] == "Amex"){'checked="checked"';} ?> id="Amex" />
    Amex</label>
</span>

  <span id="sprytextfield21">
  <label for="CardNum">Card Number:</label>
  <input type="text" name="CardNum" id="CardNum" value='<?php echo htmlentities($CardNum) ?>' />
  <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
  <br />
  <br />

  <span id="sprytextfield18">
  <label for="exp">EXP:</label>
  <input name="exp" type="text" id="exp" size="10" maxlength="5" value='<?php echo htmlentities($exp) ?>' />
  </span>

  <span id="sprytextfield20">
  <label for="cvs">CVS #:</label>
  <input name="cvs" type="text" id="cvs" size="5" maxlength="3" value='<?php echo htmlentities($cvs) ?>' />
  <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
  <br />
  <br />
  <span id="sprytextfield19">
  <label for="auth">Name on Card:</label>
  <input name="auth" type="text" id="auth" size="40" value='<?php echo htmlentities($auth) ?>' />
</span>
</div>

<div id="delivery">
    <p>Please allow 3 weeks for delivery.
    <br />
    <br />
    Orders will ship via UPS Ground. Individual product styles will ship separately.
  </p>
</div>

    <br />
<ul>
  <li class="clear">PERSONALIZATION INFORMATION</li>
</ul>

<div id="pers_form">
<span id="sprytextfield3">
    <label for="First">First Name:</label>
    <input type="text" name="First" id="First" value='<?php echo htmlentities($First) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span></span>

<span id="sprytextfield2">
    <label for="Last">Last Name:</label>
    <input type="text" name="Last" id="Last" value='<?php echo htmlentities($Last) ?>' />
    <span class="textfieldRequiredMsg">A value is required.</span></span><br /><br />

<span id="sprytextfield4">
    <label for="Phone2">Phone #:</label>
    <input type="text" name="Phone2" id="Phone2" value='<?php echo htmlentities($Phone2) ?>' />
    <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>

<span id="sprytextfield1">
    <label for="Email2">Email:</label>
    <input type="text" name="Email2" id="Email2" value='<?php echo htmlentities($Email2) ?>' />
    <span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
</div>

<div id="totals_header">
TOTAL COST
</div>

    <br />
<ul>
  <li>ITEM</li>
</ul>

<div id="item_form">
  <h3>Executive Metal Grip Roller</h3>
    <input name="ItemNum" type="hidden" id="ItemNum" value="EMGR" />
    <br />
    <input name="ItemPrice" type="text" id="ItemPrice" value="$1.10 Each" size="12" readonly="readonly" />
    <br />
    <br />
<span id="sprytextfield6">
<label for="Qty">Qty (Minimum 300):</label>
<input name="Qty" type="text" id="Qty" size="10" value='<?php echo htmlentities($Qty) ?>' />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldMinValueMsg"><br />The entered value is less than the minimum required.</span></span><br />
    <br />
    <hr />
    <label for="Total">Total:</label>
    <input name="Total" type="text" id="Total" size="25" readonly="readonly" />
</div>

<div id="totals_form">
  <label for="Subtotal">Subtotal</label>
  <input name="Subtotal" type="text" id="Subtotal" size="15" readonly="readonly" />
  <br />
  <br />
  <label for="Sales_Tax">Sales Tax (MN only)</label>
  <input name="Sales_Tax" type="text" id="Sales_Tax" size="15" />
  <br />
  <br />
  <label for="P_H">Packaging and Handling</label>
  <input name="P_H" type="text" id="P_H" value="$3.75" size="15" readonly="readonly" />
  <br />
  <br />  
  <label for="Freight">Freight</label>
  <input name="Freight" type="text" id="Freight" size="15" readonly="readonly" />
  <br />
  <hr />
  <label for="Totals">Total</label>
  <input name="Totals" type="text" id="Totals" size="15" readonly="readonly" />
</div>

<div id="thank_you">
    <center><h3>Thank you for your order!</h3>
    <p class="font_red">Please verify the information and click the button to submit your order.</p>
    <br />
    <input name="Confirm" type="submit" class="font_bold" value="Confirm" />
    </center>
</div>

<div class="clear"><!--CLEAR--></div>

</form>

<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "email", {isRequired:false, useCharacterMasking:true});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["change"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["change"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "phone_number", {isRequired:false, useCharacterMasking:true});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "email", {validateOn:["change"], useCharacterMasking:true});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "integer", {minValue:300, validateOn:["change"]});
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "date", {useCharacterMasking:true});
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "phone_number", {useCharacterMasking:true});
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9");
var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10");
var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11");
var sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12", "phone_number", {useCharacterMasking:true});
var sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13", "email", {validateOn:["change"], useCharacterMasking:true});
var sprytextfield14 = new Spry.Widget.ValidationTextField("sprytextfield14");
var sprytextfield15 = new Spry.Widget.ValidationTextField("sprytextfield15");
var sprytextfield16 = new Spry.Widget.ValidationTextField("sprytextfield16", "integer");
var sprytextfield17 = new Spry.Widget.ValidationTextField("sprytextfield17", "date", {useCharacterMasking:true});
var spryradio1 = new Spry.Widget.ValidationRadio("spryradio1", {isRequired:false});
var sprytextfield18 = new Spry.Widget.ValidationTextField("sprytextfield18", "none", {isRequired:false});
var sprytextfield19 = new Spry.Widget.ValidationTextField("sprytextfield19", "none", {isRequired:false});
var sprytextfield20 = new Spry.Widget.ValidationTextField("sprytextfield20", "integer", {isRequired:false});
//-->
</script>
</body>
</html>

3 个答案:

答案 0 :(得分:2)

您可以检查该变量的$ _POST数组,然后设置检查状态。像这样:

<input type="radio" name="example" value="1"<?php echo 'Visa' == $_POST['cc'] ? ' checked="checked"' : ''; ?>/>

答案 1 :(得分:1)

忘记我之前展示的$_SESSION方法

用它来读取值:

$cc = strip_tags($_POST['cc']);

这是以表格形式检查:

<span id="spryradio1">
  <label>
    <input type="radio" name="cc" value="Visa" <?php echo if($cc == "Visa"){'checked="checked"';} ?> id="Visa"  />
    Visa</label>
  <br />
  <label>
    <input type="radio" name="cc" value="Master" <?php echo if($cc == "Master"){'checked="checked"';} ?> id="Master" />
    Mastercard</label>
  <br />
  <label>
    <input type="radio" name="cc" value="Amex" <?php echo if($cc == "Amex"){'checked="checked"';} ?> id="Amex" />
    Amex</label>
</span>

答案 2 :(得分:0)

对于每个输入无线电字段,请尝试使用<?php echo 'checked="checked"' if $_POST['cc']=='Master'; ?>(更改“Master”以匹配每个的单选框值的值。只需使用<?php echo 'checked="checked"'; ?>保证最后一个将被检查,因为每个单选按钮上都有'checked="checked"'