<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[javascript] problema con checkbox funzionante solamente al secondo &quot;tentativo&quot;]]></title><description><![CDATA[<p dir="auto">Ho un probelma con un  codice javascript associato a un checkbox</p>
<p dir="auto">Se inizialmente il checkbox non è selzionato nessun problema, funziona tutto a meraviglia, se invece ha l'attributo checked settato a checked:<br />
-la visualizzazione iniziale è corretta<br />
-quando deseleziono il checkbox i capi day[day], day[month] e day[year] vengono correttamente modificati, mentre time e type[] rimangono come se il checkbox fosse selezionato</p>
<ul>
<li>se riseleziono la visualizzazione è esatta</li>
<li>se deseleziono nuovamente la visualizzazione è esatta</li>
</ul>
<p dir="auto">Ecco il codice, spero che possiate aiutarmi!!</p>
<pre><code>function NoScad(){

    ElCheck=document.getElementById('senzaScad');
    if(ElCheck.checked==true){
        vDay="00";
        vMonth="00";
        vYear="0000";
        incombente=1;
        stato=true;
        ora="00:00";
        tipo="hidden";
    }
    else{
        var data = new Date();
        vDay=data.getDate();
        if (vDay &lt; 10) vDay = "0" + vDay;
        vMonth=data.getMonth()+1;
        if (vMonth &lt; 10) vMonth = "0" + vMonth;
        vYear=data.getFullYear();
        incombente=0;
        stato=false;
        tipo="text";
    }

    arrCaselleInput = document.getElementsByTagName("input");
    for (i = 0; i &lt; arrCaselleInput.length; i++)
    {
        switch (arrCaselleInput[i].name) 
        {  
            case "day[day]":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = vDay;
            
              break;
            case "day[month]":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = vMonth;
            
              break;
            case "day[year]":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = vYear;
            
              break;
            case "time":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = ora;
            
              break;
        }
    }
    
    // se selezionato senza scadenza automaticamente incombente
    arrSelect = parent.document.getElementsByTagName("SELECT");
    for (i = 0; i &lt; arrSelect.length; i++)
    {
        switch (arrSelect[i].name) 
        {  
            case "type[]":
                arrSelect[i].disabled = stato;
                arrSelect[i].value = incombente;
                
            break;

        }
    }

    
}
</code></pre>
]]></description><link>https://dev.connect.gt/topic/150776/javascript-problema-con-checkbox-funzionante-solamente-al-secondo-quot-tentativo-quot</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 13:26:59 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/150776.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 May 2011 16:01:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [javascript] problema con checkbox funzionante solamente al secondo &quot;tentativo&quot; on Wed, 04 May 2011 16:01:46 GMT]]></title><description><![CDATA[<p dir="auto">Alla fine il problema era proprio che non era inizializzata la variabile ora nel ciclo else</p>
]]></description><link>https://dev.connect.gt/post/1002640</link><guid isPermaLink="true">https://dev.connect.gt/post/1002640</guid><dc:creator><![CDATA[ali7p]]></dc:creator><pubDate>Wed, 04 May 2011 16:01:46 GMT</pubDate></item><item><title><![CDATA[Reply to [javascript] problema con checkbox funzionante solamente al secondo &quot;tentativo&quot; on Wed, 04 May 2011 13:51:29 GMT]]></title><description><![CDATA[<p dir="auto">Ecco qui la pagina con il mio problema:<br />
<a href="http://nuvolacoccola.altervista.org/prova.html" rel="nofollow ugc">nuvolacoccola.altervista.org/prova.html</a></p>
<p dir="auto">Quando deseleziono la checkbox la prima volta la select rimane bloccata, riseleziono e rideseleziono e funziona</p>
<p dir="auto">di seguito tutto il codice</p>
<pre><code>&lt;script type="text/javascript"&gt;
function NoScad(){

    ElCheck=document.getElementById('senzaScad');
    if(ElCheck.checked){
        vDay="00";
        vMonth="00";
        vYear="0000";
        incombente=1;
        stato=true;
        ora="00:00";
        tipo="hidden";
    }
    else{
        var data = new Date();
        vDay=data.getDate();
        if (vDay &lt; 10) vDay = "0" + vDay;
        vMonth=data.getMonth()+1;
        if (vMonth &lt; 10) vMonth = "0" + vMonth;
        vYear=data.getFullYear();
        incombente=0;
        stato=false;
        tipo="text";
    }

    arrCaselleInput = document.getElementsByTagName("input");
    for (i = 0; i &lt; arrCaselleInput.length; i++)
    {
        switch (arrCaselleInput[i].name) 
        {  
            case "day[day]":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = vDay;
            
              break;
            case "day[month]":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = vMonth;
            
              break;
            case "day[year]":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = vYear;
            
              break;
            case "time":
            arrCaselleInput[i].type = tipo;
            arrCaselleInput[i].value = ora;
            
              break;
        }
    }
    
    // se selezionato senza scadenza automaticamente incombente
    arrSelect = parent.document.getElementsByTagName("select");
    for (i = 0; i &lt; arrSelect.length; i++)
    {
        switch (arrSelect[i].name) 
        {  
            case "type[]":
                arrSelect[i].disabled = stato;
                arrSelect[i].value = incombente;
                
            break;

        }
    }

    
}
&lt;/script&gt;

&lt;select name="type[]" id="type[]" disabled="true"&gt;
&lt;option value=""&gt;Seleziona&lt;/option&gt;
&lt;option value="1"&gt;1&lt;/option&gt;
&lt;option value="2"&gt;2&lt;/option&gt;
&lt;option value="3"&gt;3&lt;/option&gt;
&lt;option value="4"&gt;4&lt;/option&gt;
&lt;option value="5"&gt;5&lt;/option&gt;
&lt;option value="6"&gt;6&lt;/option&gt;
&lt;/select&gt;
&lt;input type="checkbox" name="senzaScad" id="senzaScad" value="1" onchange="NoScad();" checked="checked"/&gt;
&lt;input type="text" name="day[day]" id="day[day]" /&gt;
&lt;input type="text" name="day[month]" id="day[month]" /&gt;
&lt;input type="text" name="day[year]" id="day[year]" /&gt;
&lt;input type="text" name="time" id="time" /&gt;
</code></pre>
<p dir="auto">Nessuno può aiutarmi, please?</p>
]]></description><link>https://dev.connect.gt/post/1002639</link><guid isPermaLink="true">https://dev.connect.gt/post/1002639</guid><dc:creator><![CDATA[ali7p]]></dc:creator><pubDate>Wed, 04 May 2011 13:51:29 GMT</pubDate></item></channel></rss>