Results 1 to 5 of 5

Thread: innterHTML disappears so fast

  1. #1
    Join Date
    Jun 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up innterHTML disappears so fast

    when you click "kontrol et " button the message "alan boş olamaz" loading and disappears so fast,how can i make it stay...

    innerHMTL --> ad_kontrol.innerHTML="<img src=\"yukleniyor.gif\" />alan boş olamaz!";

    thank you very much ...

    Code:
    <script>
    
    function carp(form){
    
    var s1=form.ilk_sayi.value;
    var s2=form.ikinci_sayi.value;
    var sonuc;
    
    //rakamlari kontrol et
    
    if(isNaN(s1) || isNaN(s2) ){
    alert('geçersiz sayi');
    }
    else{
    //eval ile isleme sok busayade sayilar tamsayi olacak
    carp= eval(s1) * eval(s2);
    
    //cevap alanini olustur
    
    form.cevap.value=carp;
    }
    }
    </script>
    
    <style>
    #ad_kontrol{
    padding-left:6px;
    color:#FF0000;
    }
    </style>
    </head>
    
    <body>
    <script>
    function ad_alan_kontrol(form){
    
    //ad metin alanini kontrol et
    if(form.ad.value==""){
    var ad_kontrol=document.getElementById('ad_kontrol');
    ad_kontrol.innerHTML="<img src=\"yukleniyor.gif\" />alan boş olamaz!";
    }
    }
    </script>
    <form id="form" name="form1" method="post" action="">
    
    adınız: 
    <input type="text" name="ad" /><span id='ad_kontrol'></span><p>
    <label>
    <input type="submit" name="Submit" onclick='ad_alan_kontrol(this.form)' value="kontrol et" />
    </label>
    <p>iki sayı girin:</p>
    <p>ilk sayı: 
      <input type="text" name="ilk_sayi" />
    </p>
    <p>ikinci sayı: 
      <input type="text" name="ikinci_sayi" />
    </p>
    <p>
      <input type="submit" name="Submit2" onclick='carp(this.form)' value="ÇARP" />
    </p>
    <p>sonuç:
      <input type="text" name="cevap" />
    </p>
    <p>
      <input type="reset" name="Submit3" value="Temizle" />
    </p>
    </form>

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    if its a temporary element meant to only run while the script is being processed, then it would be wise to not "delay" the page from actually processing and/or displaying the contents accordingly

  3. #3
    Join Date
    Jun 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    may you show with a fugitive script(example)?

  4. #4
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    It's because you are using the submit button. By default, the submit button, submits the form which reloads the page then.
    The fix is by changing the highlighted to button instead:
    Code:
    <input type="submit" name="Submit" onclick='ad_alan_kontrol(this.form)' value="kontrol et" />
    Hope it helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  5. #5
    Join Date
    Jun 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    it works .. thank you very much ..

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
  •