English 中文(简体)
未定义的形式
原标题:form not defined in Firefox

i m 试图获得要素选择的价值:

<div id="decorazioni_agg">Decorazioni aggiuntive:<br>
        <select id="decorazioni" name="decorazioni">
            <option class="option" value="smarties">Smarties</option>
            <option class="option" value="scaglie">Scaglette di
                            cioccolato</option>
            <option class="option" value="cheerios">Cheerios</option>
            <option class="option" value="chocopops">Choco 
                            Pops</option>
        </select><br>

        <input class="button" name="aggiungi" type="button" value="Aggiungi 
                    decorazione" onClick="add_decoration(decorazioni.value)">
    </div>

And this is the function add_decoration(obj):

function add_decoration(tipo)
{
if(tipo ==  smarties )
    add_smarties();
else
    add_something(tipo);
}

现在,这既与 Chrome和IE8合作,又与L.3.5不合作。

decorazioni is not defined

How can i do without using a bunch of switch so i can keep my code clean? Thanks in advance

问题回答
onclick="var elem = document.getElementById( decorazioni ); add_decoration(elem.options[elem.selectedIndex].value);"

然而,最好利用适当的活动登记而不是在线活动。 这里举一个 j,让纽子获得补助:

$( #buttonid ).on( click , function() {
    add_decoration($( #decorazioni ).val());
});

不受超文本约束的事件处理人员。

<input class="button" id="aggiungi" name="aggiungi" type="button" value="Aggiungi decorazione" />

document.getElementById( aggiungi ).onclick= function () {
    add_decoration(document.getElementById( decorazioni ).value);
};




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签