在同一个jsp页面上显示html表单

时间:2015-12-28 11:58:07

标签: jsp

在提到的图片中,如果我点击"添加新按钮"然后我的html表单应该在同一页面上(gold.jsp页面)。但是它会转到另一个jsp页面(这里的javascript代码中提到的additem.jsp),如何在gold.jsp页面本身上显示它,它就是additem。 jsp在这里。 enter image description here

这是我的gold.jsp页面编码,这里我在jsp中使用了javascript。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert gold</title>
</head>

<style type = "text/css">
body
{
background-color:black;
}
p
{
color:yellow;
}

button
{
background-color:yellow;

}


p
{
color:yellow;
}
</style>
<script type ="text/javascript">
function onsubmitform()
{
    if(document.pressed == "insert")
        {

        document.myform.action = "additem.jsp";


        }

    else if(document.pressed == "addstock")
    {

    document.myform.action = "display.jsp";
    }

    }









</script>
<body>
<hr/>

<img src = "C:\Users\ms trapti\workspace\jewellery\WebContent\images\images2.jpg"   width = "50px" height = "50px" vspace = "5px"/>
<center><img src = "E:\jewellery 18-dec\18decjewry\jewellerynew\WebContent\images\untitled2.png" alt = "gold" width = "60px" height = "60px"></img></center>
<p><i>Trapti jewellery</i></p>
<center><p> Gold Management System</p></center><br/>

<div style = "position:fixed;  left: 300px; bottom: 130px;" >
<p>Tray No:<select>
<option value ></option>
</p>
</select>
</div>

<table>

<form name = "myform" onsubmit = "return onsubmitform();">
<button type = "submit" name = "operation" onclick = "document.pressed = this.value" value = "addstock">Add new Stock</button><br/><br/>



<button type = "submit" name = "operation" onclick = "document.pressed = this.value" value = "insert">Add new Item</button><br/><br/>
<button type = "submit" name = "operation" onclick = "document.pressed = this.value" value = "insert">Delete Item</button><br/><br/>



<button type = "submit" name = "operation" onclick = "document.pressed = this.value" value = "update">Purchase</button><br/><br/>
<button type = "submit">Sales</button><br/><br/>

</form>
</table>




</body>
</html>

1 个答案:

答案 0 :(得分:0)

您可以使用简单的AJAX请求从服务器加载部分JSP页面:

FORM_DIRECTIVES

这是你要找的吗?