验证用户条目的Javascript,然后通过选项表单的弹出框显示任何错误?

时间:2013-07-01 02:34:35

标签: javascript html

我很难设法创建一个javascript文件来验证我的样本表单的选项和数量。我试图做的是当一个人填写表格并且出错时,我想要弹出一个说明原因。如果它的好,典型的显示将是订购项目的摘要,每个项目的数量,每个项目的成本和总成本。

简而言之,如果客户订购了某些东西,我希望显示屏能够显示他们订购的产品以及含税总额。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
            <title>Products & Services</title>
    </head>
    <body>
        <h1>PC Products</h1>

    <form action="" name="products" method="POST">
    <table summary="Feedback">
    <tr>
    <td>Processors:

  <select name="product1">
      <option>Select Device</option>
       <option value="139.99">Intel i3 - $140</option>
       <option value="189.99">Intel i5 - $190</option>
       <option value="239.99">Intel i7 - $240</option>
       </select>

    Quantity :
  <select name="quantity1" >
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    </tr>
    </td>

        <tr>
    <td>Storage:

  <select name="product2">
      <option>Select Device</option>
       <option value="149.99">SSD 128GB - $149.99</option>
       <option value="249.99">SSD 256GB - $249.99</option>
       <option value="519.00">SSD 512GB - $519.00</option>
       <option value="69.99">HDD 500GB - $69.99</option>
       <option value="109.99">HDD 1TB - $109.99</option>
       <option value="149.99">HDD 1.5TB - $149.99</option>
       <option value="199.99">HDD 3TB - $199.99</option>
    </select>

    Quantity :
  <select name="quantity2" >
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    </tr>
    </td>
        <tr>
    <td>
  Memory:

  <select name="product3">
      <option>Select Device</option>
       <option value="59.99">DDR3 8GB - $59.99</option>
       <option value="109.99">DDR3 16GB - $109.99</option>
       <option value="209.99">DDR3 32GB - $209.99</option>

    </select>
    Quantity :
  <select name="quantity3" >
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    </tr>
    </td>

        <tr>
    <td>Graphics Card:

  <select name="product4">
      <option>Select Device</option>
       <option value="139.99">Nvidia - $649.99</option>
       <option value="189.99">AMD - $449.99</option>
       </select>

    Quantity :
  <select name="quantity4" >
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    </tr>
    </td>
    <br />

<table> Service and Repair  
<tr><td><input type="checkbox" name="service" value="99.99">
  <td>Virus Removal</td> <td align="right"><tt>99.99</tt></td></tr>
<tr><td><input type="checkbox" name="service" value="29.99">
  <td>1 Hour Computer Lessons</td> <td align="right"><tt>29.99</tt></td></tr>
  <tr><td><input type="checkbox" name="service" value=49.99">
  <td>PC Assembly</td> <td align="right"><tt>49.99</tt></td></tr>

</table>
    <br />

    <h4><i>*Sales Tax of 8.25% applies</i></h4>
    <td>Tax exempt check box:
<input type="checkbox" name="reply" value="yes" /><br />

    <p>
    <input type="hidden" id="itemname" name = "itemname" value= "">
                <input type = "submit" value="Submit" />
                <input type = "reset" value="Clear" />
            </p>
            </td>
            </form>
        </body>
    </html>

0 个答案:

没有答案