Bonjour à tous,
Ce script fonctionne à merveille s'il n'y a qu'un seul formulaire dans la page.
Par contre s'il y en a plusieurs, l'alert déconne complètement à partir du 2ème (le premier fonctionne).
Exemple :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<script type="text/javascript">
function verifFormul(Stylo) {
if (document.getElementById('handling_cart').options[0].selected) {
alert('Veuillez sélectionner un pays de destination.');
return false;
}
return true;
}
</script>
<!-- Start of Script --><script language="javascript">
function CalculateOrderStylo(form)
{
if (form.os0.value == "Suisse" )
{
form.shipping.value = "1.50"; form.shipping2.value = "";
}
if (form.os0.value == "UE" )
{
form.shipping.value = "2.70"; form.shipping2.value = "";
}
if (form.os0.value == "Autre" )
{
form.shipping.value = "3.50"; form.shipping2.value = "";
}
}
</script><!-- End of Script --><!-- Start of Form -->
<form name="Stylo" action="https://www.paypal.com/cgi-bin/webscr" onsubmit="return (verifFormul(this));" method="post" target="paypal">
<table border="0" cellpadding="1" width="390">
<tbody>
<tr>
<td height="114" width="258">
<p align="center"><font face="Verdana" size="3"><strong>Vaporisateur Melt-em 8 ml</strong></font><br />
<br />
<!-- --> <font face="Verdana, Arial, Helvetica, sans-serif" size="3"><strong>Qté </strong> </font> <input name="quantity" size="3" type="text" value="1" width="50" /> <!-- --> <input name="cmd" type="hidden" value="_xclick" /> <input name="business" type="hidden" value="mon@dresseema.il" /> <input name="item_name" type="hidden" value="Vaporisateur Melt-em 8ml" /> <input name="amount" type="hidden" value="2.90" /> <input name="item_number" type="hidden" value="8" /> <input name="no_shipping" type="hidden" value="2" /> <input name="shipping" type="hidden" /> <input name="shipping2" type="hidden" /> <input name="return" type="hidden" value="http://www.melt-em.ch" /> <input name="cancel_return" type="hidden" value="http://www.yourwebsite.com/cancel.html" /> <input name="currency_code" type="hidden" value="CHF" /> <input name="lc" type="hidden" value="FR" /> <input name="cpp_header_image" type="hidden" value="http://cdwebdesign.ws/dav/c/cdwebdesign.ws//cachedImages/2556.png" /> <input name="bn" type="hidden" value="PP-ShopCartBF:btn_buynow_LG.gif:NonHosted" /> <input align="top" alt="Effectuer ses paiements avec Paypal - une solution rapide, gratuite et sûre !" border="0" onclick="CalculateOrderStylo(this.form)" src="https://www.paypal.com/fr_FR/i/btn/btn_buynow_LG.gif" type="image" /></p>
</td>
<td width="55">
<div align="center"><img alt="" border="0" class="lightbox" src="http://217.196.177.129/wcms/ftp/c/cdwebdesign.ws/siteimages/2602.jpg" width="65" /></div>
</td>
<td width="63">
<div align="center"><font face="Verdana" size="3"><strong>CHF 2.90</strong></font></div>
</td>
</tr>
</tbody>
</table>
<input name="on0" type="hidden" value="Option d'envoi" /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Option d'envoi : </font> <select id="handling_cart" name="os0"> <option value="">Sélectionner</option> <option value="Suisse">Suisse CHF 1.50</option> <option value="UE">UE CHF 2.70</option> <option value="Autre">Autre CHF 3.50</option> </select></form>
<!-- End of Form -->
<script type="text/javascript">
function verifFormul(Bottle) {
if (document.getElementById('handling_cart').options[0].selected) {
alert('Veuillez sélectionner un pays de destination.');
return false;
}
return true;
}
</script>
<!-- Start of Script --><script language="javascript">
function CalculateOrderBottle(form)
{
if (form.os0.value == "Suisse" )
{
form.shipping.value = "7.50"; form.shipping2.value = "";
}
if (form.os0.value == "UE" )
{
form.shipping.value = "15.50"; form.shipping2.value = "";
}
if (form.os0.value == "Autre" )
{
form.shipping.value = "18.00"; form.shipping2.value = "";
}
}
</script><!-- End of Script --><!-- Start of Form -->
<form name="Bottle" action="https://www.paypal.com/cgi-bin/webscr" onsubmit="return (verifFormul(this));" method="post" target="paypal">
<table border="0" cellpadding="1" width="390">
<tbody>
<tr>
<td height="114" width="258">
<p align="center"><font face="Verdana" size="3"><strong>Vaporisateur Melt-em 75 ml</strong></font><br />
<br />
<!-- --> <font face="Verdana, Arial, Helvetica, sans-serif" size="3"><strong>Qté </strong> </font> <input name="quantity" size="3" type="text" value="1" width="50" /> <!-- --> <input name="cmd" type="hidden" value="_xclick" /> <input name="business" type="hidden" value="mon@dresseema.il" /> <input name="item_name" type="hidden" value="Vaporisateur Melt-em 75ml" /> <input name="amount" type="hidden" value="9.90" /> <input name="item_number" type="hidden" value="75" /> <input name="no_shipping" type="hidden" value="2" /> <input name="shipping" type="hidden" /> <input name="shipping2" type="hidden" /> <input name="return" type="hidden" value="http://www.melt-em.ch" /> <input name="cancel_return" type="hidden" value="http://www.yourwebsite.com/cancel.html" /> <input name="currency_code" type="hidden" value="CHF" /> <input name="lc" type="hidden" value="FR" /> <input name="cpp_header_image" type="hidden" value="http://cdwebdesign.ws/dav/c/cdwebdesign.ws//cachedImages/2556.png" /> <input name="bn" type="hidden" value="PP-ShopCartBF:btn_buynow_LG.gif:NonHosted" /> <input align="top" alt="Effectuer ses paiements avec Paypal - une solution rapide, gratuite et sûre !" border="0" onclick="CalculateOrderBottle(this.form)" src="https://www.paypal.com/fr_FR/i/btn/btn_buynow_LG.gif" type="image" /></p>
</td>
<td width="55">
<div align="center"><img alt="" border="0" class="lightbox" src="http://217.196.177.129/wcms/ftp/c/cdwebdesign.ws/siteimages/2601.jpg" width="35" /></div>
</td>
<td width="63">
<div align="center"><font face="Verdana" size="3"><strong>CHF 9.90</strong></font></div>
</td>
</tr>
</tbody>
</table>
<input name="on0" type="hidden" value="Option d'envoi" /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Option d'envoi : </font> <select id="handling_cart" name="os0"><option value="">Sélectionner</option><option value="Suisse">Suisse CHF 7.50</option><option value="UE">UE CHF 15.50</option><option value="Autre">Autre CHF 18.00</option> </select></form>
<!-- End of Form -->
<script type="text/javascript">
function verifFormul(Mix) {
if (document.getElementById('handling_cart').options[0].selected) {
alert('Veuillez sélectionner un pays de destination.');
return false;
}
return true;
}
</script>
<!-- Start of Script --><script language="javascript">
function CalculateOrderMix(form)
{
if (form.os0.value == "Suisse" )
{
form.shipping.value = "7.50"; form.shipping2.value = "";
}
if (form.os0.value == "UE" )
{
form.shipping.value = "15.50"; form.shipping2.value = "";
}
if (form.os0.value == "Autre" )
{
form.shipping.value = "18.00"; form.shipping2.value = "";
}
}
</script><!-- End of Script --><!-- Start of Form -->
<form action="https://www.paypal.com/cgi-bin/webscr" onsubmit="return (verifFormul(this));" method="post" target="paypal">
<table border="0" cellpadding="1" width="390">
<tbody>
<tr>
<td height="114" width="258">
<p align="center"><font face="Verdana" size="3"><strong>Vaporisateur Melt-em Mix</strong></font><br />
<br />
<!-- --> <font face="Verdana, Arial, Helvetica, sans-serif" size="3"><strong>Qté </strong> </font> <input name="quantity" size="3" type="text" value="1" width="50" /> <!-- --> <input name="cmd" type="hidden" value="_xclick" /> <input name="business" type="hidden" value="mon@dresseema.il" /> <input name="item_name" type="hidden" value="Vaporisateur Melt-em Mix" /> <input name="amount" type="hidden" value="11.90" /> <input name="item_number" type="hidden" value="Mix" /> <input name="no_shipping" type="hidden" value="2" /> <input name="shipping" type="hidden" /> <input name="shipping2" type="hidden" /> <input name="return" type="hidden" value="http://www.melt-em.ch" /> <input name="cancel_return" type="hidden" value="http://www.yourwebsite.com/cancel.html" /> <input name="currency_code" type="hidden" value="CHF" /> <input name="lc" type="hidden" value="FR" /> <input name="cpp_header_image" type="hidden" value="http://cdwebdesign.ws/dav/c/cdwebdesign.ws//cachedImages/2556.png" /> <input name="bn" type="hidden" value="PP-ShopCartBF:btn_buynow_LG.gif:NonHosted" /> <input align="top" alt="Effectuer ses paiements avec Paypal - une solution rapide, gratuite et sûre !" border="0" onclick="CalculateOrderMix(this.form)" src="https://www.paypal.com/fr_FR/i/btn/btn_buynow_LG.gif" type="image" /></p>
</td>
<td width="55">
<div align="center"><img alt="" border="0" class="lightbox" src="http://217.196.177.129/wcms/ftp/c/cdwebdesign.ws/siteimages/2603.jpg" width="65" /></div>
</td>
<td width="63">
<div align="center"><font face="Verdana" size="3"><strong>CHF 11.90</strong></font></div>
</td>
</tr>
</tbody>
</table>
<input name="on0" type="hidden" value="Option d'envoi" /> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Option d'envoi : </font> <select id="handling_cart" name="os0"><option value="">Sélectionner</option><option value="Suisse">Suisse CHF 7.50</option><option value="UE">UE CHF 15.50</option><option value="Autre">Autre CHF 18.00.</option> </select><br />
</form>
<!-- End of Form -->
</div>
</body>
</html>
Si quelqu'un a une idée, elle sera la bienvenue.
Merci d'avance.