PDA

View Full Version : Body onload problem



sir_yunus
03-09-2008, 04:51 PM
when the page open i want to get the area's content to hide element but it cant how can i do i want control if area's content change or not
Js code



function ata()
{
var deneme=document.getElementById('icerik').value;
deneme=document.getElementById('area').innerHTML;
alert(deneme);
}
function deneme(){
var deneme=document.getElementById('icerik').value;
var deneme1=document.getElementById('area').innerHTML;
if ('deneme'=='deneme1'){
alert(deneme)}
}


Body part




<body onload="ata()"><div id="area" contenteditable="true"> Content</div> <div><input type="hidden" id="icerik" name="icerik" />


i cant make when page onload area value to hidden .in my this code hidden value ="" is like that

codeexploiter
03-10-2008, 05:38 AM
I've modified the functions you've provided in the following manner:


function ata(){
document.getElementById('icerik').value = document.getElementById('area').innerHTML;
}

function deneme(){
var deneme1 = document.getElementById('icerik').value;
var deneme2 = document.getElementById('area').innerHTML;

if(deneme1 == deneme2){
alert(deneme1);
}
}

Now if you wish to invoke the ata method while loading the window, add the following line within your <script> section


window.onload = ata;

Now you can remove the onload attribute form the <body> element.

I don't know where exactly you invoke the deneme method.