• 03-09-2015, 00:30:49
    #1
    Üyeliği durduruldu
    <body>
    <script>
    function topla( ){
    str=0;
    count = 0;
    for(var x=0; x<document.form1.elements["topla[]"].length; x++ ){
    if(document.form1.elements["topla[]"][x].checked==true ){
    str =str+ Number(document.form1.elements["topla[]"][x].value );
    }
    }
    document.form1.toplam.value=str.toFixed(2 );
    }
    </script>
    <form name="form1" id="form1" >
    <input type="checkbox" name="topla[]" value="5" onclick="topla( )"/>Evet
    <input type="checkbox" name="topla[]" value="0" onclick="topla( )"/>Hayır 
    
    <label>Toplam: </label> <input type="text" name="toplam" value="" />
    </form>
    </body>
    [/PHPR] burada bunu form name="form1" id="form1" kullanmadan yapamam mı acaba ?
  • 04-09-2015, 03:51:22
    #2
    özelden yanıt vermiştim fakat birilerinin işine yarar belki;

    document.form1 yerine şöyle de kullanabilirsiniz
    document.forms[0]
    ya da document.forms.item(0)

    bu form sayfadaki kaçıncı formsa ona göre 0'dan başlayarak dizi mantığında erişebilirsiniz.
    yani erişeceğiniz form html içinde üçüncü form ise
    document.forms[2].elements...
    şeklinde...

    iyi çalışmalar.

    Xylia adlı üyeden alıntı: mesajı görüntüle
    <body>
    <script>
    function topla( ){
    str=0;
    count = 0;
    for(var x=0; x<document.form1.elements["topla[]"].length; x++ ){
    if(document.form1.elements["topla[]"][x].checked==true ){
    str =str+ Number(document.form1.elements["topla[]"][x].value );
    }
    }
    document.form1.toplam.value=str.toFixed(2 );
    }
    </script>
    <form name="form1" id="form1" >
    <input type="checkbox" name="topla[]" value="5" onclick="topla( )"/>Evet
    <input type="checkbox" name="topla[]" value="0" onclick="topla( )"/>Hayır 
    
    <label>Toplam: </label> <input type="text" name="toplam" value="" />
    </form>
    </body>
    [/PHPR] burada bunu form name="form1" id="form1" kullanmadan yapamam mı acaba ?