Results 1 to 2 of 2

Thread: Body onload problem

  1. #1
    Join Date
    Feb 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Body onload problem

    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
    HTML Code:
    [COLOR="DarkRed"]function ata()[/COLOR]
    {
    var deneme=document.getElementById('icerik').value;
    deneme=document.getElementById('area').innerHTML;
    alert(deneme);
    }
    [COLOR="DarkRed"]function deneme(){[/COLOR]
    var deneme=document.getElementById('icerik').value;
    var deneme1=document.getElementById('area').innerHTML;
    if ('deneme'=='deneme1'){
    alert(deneme)}
    }
    Body part

    HTML Code:
    <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

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    I've modified the functions you've provided in the following manner:

    Code:
    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

    Code:
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •