JQuery.form resetForm () does not reset default select box

I have a function that clears all elements inside a span identifier. clearForm () works, but resetForm () does not.

`<script type="text/JavaScript">`  
`    $(function hideMe() { ` 
`        for(i=0;i<arguments.length;i++) {`  
`        $("#"+arguments[i]).clearForm().fadeOut();`  
`    }`  
`    });`  
`</script>`  
`<html>`  
`...<td><input type="radio" name="third_party" id="third_partyNo" value="No" onClick="hideMe('party_integ');" />No</td>`  
'...'  
`<span id="party_integ" style="display:none">`  
`<table>`  
`    <tr>`  
` <td width="25%">System Type:</td>`  
` <td width="22%"><select name="system_type" id="system_type" class="style3" onChange="popCat(this.value);">`  
` <option value="" selected="selected">Select one</option>`  
` <option value="first">first</option>`  
` <option value="second">second</option>`  
` <option value="third">third</option>`  
` </select></td>`  
`    </tr>`  
`</table>`  
`</span>` 
+3
source share
3 answers

There are many errors in the code.

  • You declare your "hideMe" function in such a way that it does not work in browsers other than IE, and the behavior of the IE on which it relies is severely violated. You configure the function as a jQuery "ready" handler, not a global function. Instead, you should associate an anonymous function with a click event for your radio button. You can do this in the "ready" handler.

  • Function "clearForm" - what is it? Where is this defined?

  • , . <div>, .

  • reset < reset <form>. , <form>. , reset .

+1

$( "#" + []). ClearForm()

clearForm - , resetForm.

resetForm s, , .. , value="x". <form> ( <span>, ), JavaScript form.reset().

( resetForm -, value defaultValue , defaultChecked defaultSelected. , .)

clearForm, , , , . <select>? ; "no" , .

jQuery.form , " ", . 610:

    else if (tag == 'select')
        this.selectedIndex = -1;

selectedIndex -1. , 0, . ( select-many.)

jQuery.form, , .

+1

Source: https://habr.com/ru/post/1734423/


All Articles