|
-
Jul 9th, 2013, 07:48 AM
#1
Thread Starter
Frenzied Member
Re: Client side "Edit Profile" before submitting multiple values at once...
Right, think ive got it now....
it APPEARS to work with the following... (alerts show from 1-5), and then the "image" shows...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script type="text/javascript">
<!--
function AddItem(){
document.getElementById("additemDiv").innerHTML = " " +
"<fieldset id='additemform'>" +
"<div>item1: <input type='text' name='input1' id='input1' /><br />" +
"item2: <input type='text' name='input2' id='input2' /><br />" +
"item3: <input type='text' name='input3' id='input3' /><br />" +
"item4: <input type='text' name='input4' id='input4' /><br />" +
" <input type='button' onclick='InsertItem(); return false;' value='Store Value' /></div></fieldset>";
}
function InsertItem(){
alert("Insert item");
if(undefined === window.jsonelement){
window.jsonelement = { "count":0, "newitems":[]};
// write html into "not saved" div
}
alert("Insert item2");
var je = window.jsonelement;
je.newitems.push({
"item1" : document.getElementById("input1").value,
"item2" : document.getElementById("input2").value,
"item3" : document.getElementById("input3").value ,
"item4" : document.getElementById("input4").value
});
alert("Insert item 3");
var jeItem = je.newitems[je.count];
je.count++;
var itemsDiv = document.getElementById("items");
itemsDiv.innerHTML = itemsDiv.innerHTML + " <div class='item' id='newitem"+je.count+"'>"
+"<a href='"+jeItem.item3+"'>"
+"<img src='"+jeItem.item1+"' alt='"
+jeItem.item2+"' /></a><br />"
+jeItem.item4+"</div>";
alert("Insert item 4");
document.getElementById("additemDiv").innerHTML = " " +
"<a href='additem.php?op=form' onclick='AddItem(); return false;' title='add another item'>Add Item</a>";
alert("Insert item 5");
}
-->
</script>
<body>
<div id="notsaved"></div>
<h1>this is a test of adding items on the fly</h1>
<div id="items">
<div class="item"><a href="input 3"><img src="input 1" alt="input 2" /></a><br />input 4</div>
</div>
<div id="additemDiv"><a href="additem.php?op=form" onclick="AddItem(); return false;" title="add another item">Add Item</a></div>
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|