锚定为提交按钮,结果集值为href

时间:2014-04-16 07:27:04

标签: jquery html

<html><a id="fakeanchor" href="3.jsp?id=<%=request.getParameter("id")%>" >id</a>
 </html>

<script>
$("a#fakeanchor").click(function()
    {
    $("#submit_this").submit();
    return false;
    });
 </script>

我正在尝试用锚标记替换提交按钮,并将结果集值发送到数据库jsp.please告诉这里出了什么问题..

这是完整的jsp页面代码..

    <form method="POST" id="submit_this" action="3.jsp" name="form1">
   <br><br><br><br><br>
    <TABLE border="10"   width="1250">
     <CAPTION><EM>A test table with merged cells</EM></CAPTION>
     <TR><TH rowspan="2">Parameters
    <TH rowspan="2">Excellent <TH rowspan="2">Fair <TH rowspan="2">Good
    <TR><TH>Poor  
     <TR><TH height="100">Presentation Content <TD ><input type="radio" name="r" value="Excellent"/><TD               w         width="150">
     <input type="radio" name="r" value="Fair"/><TD width="100"><input type="radio" name="r" value="Good"/>
     <TD width="100"><input type="radio" name="r" value="Poor"/>
    <TR><TH height="100">Communication and Presentation Skills<TD>
     <input type="radio" name="a"  value="Excellent"/><TD><input type="radio" name="a" value="Fair"/><TD>
    <input  type="radio" name="a" value="Good"/><TD><input type="radio" name="a" value="Poor"/>
     <TR><TH height="100">Depth of Knowledge<TD><input type="radio" name="d" value="Excellent"/><TD>
      <input type="radio" name="d" value="Fair"/><TD><input type="radio" name="d" value="Good"/><TD>
      <input type="radio" name="d" value="Poor"/>
      <TR><TH height="100">Time utilization<TD><input type="radio" name="i" value="Excellent"/><TD>
      <input type="radio" name="i" value="Fair"/><TD><input type="radio" name="i" value="Good"/><TD>
      <input type="radio" name="i"   value="Poor"/>
  <TR><TH height="100">Involving Audience<TD><input type="radio" name="o" value="Excellent"/>
 <TD><input type="radio"     name="o" value="Fair"/><TD><input type="radio" name="o" value="Good"/>
 <TD><input type="radio" name="o"   value="Poor"/>


 </TABLE>


<br><br><br><br>
 <b><font size="4">Feel Free to add any comments aur suggestions</font></b><br><br>
 <textarea name="text" rows=4 cols=100></textarea>
     <br>
    <br

     <a id="fakeanchor" href="3.jsp?id=<%=request.getParameter("id")%>" >id</a>

     </form>

     i am getting an ID number from first.html and showing it on jsp page through

       ResultSet resultset = 
            statement.executeQuery("select * from register where id = '" + id + "'") ; 

        if(!resultset.next()) {

            String site = new String("http://localhost:8888/Feedback/error.html");
            response.setStatus(response.SC_MOVED_TEMPORARILY);
            response.setHeader("Location", site);
        } else {
    %>


    <center><b>
    <font size="4">WELCOME &nbsp; &nbsp;
     <%= resultset.getString(2) %> 

  that ID number should be saved along with the corresponding radio buttons,the user (same ID)clicks on.
  how do i save the resultset value to the database.
  I am sending the resultset value to other jsp which contains my database connections etc. through href.
  .thats why i want this href link to behave same like submit button.

。这样我就可以将结果集值发送到3.jsp并提交表单..

    HTML page
    <form method="GET" action="2.jsp" name="form1" target="_blank" onsubmit="setTimeout(function () 
    { window.location.reload(); }, 10)">
     <p>
    <center>
   <b><font size="6">Welcome to the feedback page</font></b>
    </center>
    </p>

     <p align="center"><br><br><br><br>
      <center>ENTER YOUR SAP ID : <input type="text" name="id"/></center><br><br>
     <center><input type="submit"  name=""  value="Submit" onClick="return (verify());"/></center>
     </p>
      </form>

1 个答案:

答案 0 :(得分:1)

首先,我想你要设置表单的3.jsp?id=..,所以在你的功能中你还需要

$("a#fakeanchor").click(function()
    {
    $("#submit_this").action($(this).href());
    $("#submit_this").submit();
    return false;
    });

我添加的这一新行会将链接的href值放在表单的action值中。

这是一个工作示例:http://jsfiddle.net/u5Fwt/2/