userDiv is a dynamically created button containing username and pic. Through a loop I have assigned the user’s name as the div/button id. Onclick it goes to another page and assigns the name of the user to var name. However, when I get to the other page I seem to be unable to add any info. I have tried a couple of different methods (see below). I get an Object[object object] when I try to append the button itself for example and document.write just turns the screen blank altogether. If someone could explain this to me and offer a solution I would be grateful.
userDiv.id=theName;
userDiv.onclick=(function() {
window.location.href = 'Createtask.html';
alert($(this).attr("id"));
name= $(this).attr("id");
makeTask();
});
};
}
function makeTask(){
function makeTask(){
document.write(name);// blank screen
//var userBtn= document.getElementById(name);
//$("#singleUser").appendChild(userBtn);//Object [object object] error
//var singleUser = document.getElementById('singleUser');
//var greetUser = document.createElement("div");
//greetUser.innerhtml='Yippee!';// can't do innerHTML of null
//singleUser.appendChild(greetUser);//can't appendChild of null
//$("#singleUser").html("Yippee");//no error, just nothing
}
}
When the page exits, you can not do anything on the next page from the previous page with JavaScript. That is what the querystring and posts requests are for. You send data to the next page and it handles it.
and on the next page you read the querystring and you can use that data.