How can I enhance the user experience by allowing them to easily update generic names (name1, name2, name3) with more meaningful ones without being redirected back to the previous name? Look for the comment WHAT GOES HERE?
below.
Example HTML layout:
<div class="name"><input type="text" id="nameinput1" value="name1" onchange="changeName(0)"></div>
<div class="name"><input type="text" id="nameinput2" value="name2" onchange="changeName(1)"></div>
<div class="name"><input type="text" id="nameinput3" value="name3" onchange="changeName(2)"></div>
Javascript code snippet:
var jsons = '[{' ;
var jsone = '"}]' ;
function changeName(index){
var json = jsons;
var name = document.getElementById("main").getElementsByTagName("input")[index].value;
json += '"index":"'+index+'",'
json += '"name":"'+name.replace(/\s/g,"")+jsone
loadDoc(json,"ID","url",returnChangeName)
}
function returnChangeName(xttp){
window.location = "#"; // WHAT GOES HERE?
}
loadDoc(...){....}
Please note that only pure Javascript is used in this functionality, no jQuery has been incorporated.