mercredi 1 avril 2015

Submit function if checkbox is checked javascript

I have a search form with a submit button with multiple functions. Each function (SubmitForm#) opens a url in a new tab: onsubmit="javascript: return (SubmitForm1() & SubmitForm2() & SubmitForm3() & SubmitForm4() & SubmitForm5() & SubmitForm6());" At this point when I click the button it submits all 6 functions and all 6 tabs open in my browser. I added 6 checkboxes with individual IDs to make the submission conditional. I would like to pair a checkbox to a function so when i click the button only those tabs open that has been checked. I cant figure it out how, please help. function example:



<script type='text/javascript'>

function SubmitForm1()
{
document.forms['search'].action=
'url';
document.forms['search'].target='_blank';
document.forms['search'].submit();
}


Checkbox example:



<label class="checkbox inline">
<input type="checkbox" id="Checkbox1" > name<br>
</label>




Aucun commentaire:

Enregistrer un commentaire