日期:2014-05-16  浏览次数:20343 次

JS传值给servlet的问题
<%@   page   language= "java "   contentType= "text/html;   charset=UTF-8 "%>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN "   "http://www.w3.org/TR/html4/loose.dtd ">
<html>
  <head>
    <title> Insert   title   here </title>
  </head>
  <body>
    <h1>
      Buy   or   Sell
    </h1>
    <form   action= "./Cortrol "   method= "post "   name= "form1 ">
      <table>
        <tr>
          <td>
            Name   :
          </td>
          <td>
            <input   type= "text "   name= "name ">
          </td>
        </tr>
        <tr>
          <td>
            Number   :
          </td>
          <td>
            <input   type= "text "   name= "number ">
          </td>
        </tr>
        <tr>
          <td>
            Price   :
          </td>
          <td>
            <input   type= "text "   name= "price ">
          </td>
        </tr>
      </table>
 
      <table>
        <td>
          <input   type= "hidden "   name= "action "   value= "buy ">
          <a   href= "# "   onclick= "document.form1.submit() "> Buy </a>
        </td>
        <td>
          <input   type= "hidden "   name= "action "   value= "sell ">
          <a   href= "# "   onclick= "document.form1.submit() "> Sell </a>
        </td>
        <td>
          <a   href= "# "   onclick= "document.form1.reset() "> Reset </a>
        </td>
      </table>
    </form>
  </body>
</html>

传递到servlet后   不管选sell还是buy,得到的action的值都是buy
有什么办法能我点那个就传那个到servlet呢????

------解决方