我有两个页面,一个是new.html,另一个是lead.html。所以,当我点击new.html中的提交按钮时,记录字段应该添加到lead.html的列表中。 这是我的代码。 new.html
//form validation
function validateForm() {
var x = document.forms["myForm"]["name"].value;
var y= document.forms["myForm"]["strtd"].value;
var z= document.forms["myForm"]["sub"].value;
if (x==null || x=="") {
alert("Record name must be filled out");
return false;
}
else if (y==null || y=="") {
alert("Started Date must be filled out");
return false;
}
else if (z==null || z=="") {
alert("Submitted Date must be filled out");
return false;
}
else {
alert("New Record Created");
var listCreated = false;
//Create the listview if not created
if(!listCreated){
$("$.content").append("<ul id='list' data-role='listview' data-inset='true' > </ul>");
listCreated = true;
$("$.content").trigger("create");
}
var value = $("$.label1").val();
$("#list").append("<li>" + value +" </li>");
$("#list").listview("refresh");
var value = $("$.label2").val();
$("#list").append("<li>" + value +" </li>");
$("#list").listview("refresh");
var value = $("$.label3").val();
$("#list").append("<li>" + value +" </li>");
$("#list").listview("refresh");
}
}
</script>
</head>
<body>
<form name="myForm" type="get" onsubmit="return validateForm()" action="lead.html">
<div id="top"> New Record</div>
<div>
<h5>Record Name <input type="text" name="RecordName" id="name"></h5>
</div>
<div >
<h5>Started Date <input id="strtd" type="text" name="StartedDate"></h5>
</div>
<div>
<h5>Submitted Date <input id="sub" type="text" name="SubmitedDate"></h5>
</div><br>
<div align="center">
<input type="submit" id="submit" value="Submit" >
</div>
</form>
<div align="center">
<button id="cancel" onclick="back()">Back</button>
</div>
</body>
和我的lead.html
<body id="lead">
<div id="top" align="center" > Leads </div>
<img id="back" src="./images/back_icon@2x.png" onclick="onBackKey()" >
<div>
<div data-role="page" style="margin-top:100px;" >
<div data-role="main" id="content">
<label id="label1" > </label><br>
<label id="label2"></label><br>
<label id="label3"></label>
<img id="arrow" src="./images/Arrow@2x.png" style="margin-left:250px" onclick="mylead1()">
</div>
</div>
</div>
</body>
请帮助我在lead.html中获取listview。