Avrei bisogno di aiuto con questo codice javascript
codice:
<script language="javascript">
function checkOrdine(){
ok = true;
if (ok && document.getElementById("conto").checked == false && document.getElementById("contrassegno").checked == false && document.getElementById("carta").checked == false && document.getElementById("ritiro").checked == false) { alert("Impossibile ordinare senza scegliere il tipo di pagamento.");ok =false;}
if (ok && document.getElementById("accetto").checked == false) { alert("Impossibile ordinare senza accettare le condizioni.");ok =false;}
if (ok && document.getElementById("carta").checked == true)
{
if ( (Trim(document.getElementById("ccTitolare").value) == "") || (Trim(document.getElementById("ccNumero").value) == "")
|| (document.getElementById("ccAnno").selectedIndex == 0) || (document.getElementById("ccMese").selectedIndex == 0) ||
(document.getElementById("ccVisa").checked == false && document.getElementById("ccMastercard").checked == false) )
{
alert('Impossibile procedere senza tutti i dati della carta di credito!');
ok = false;
}
}
if (ok) {
document.getElementById("ordina").submit();
}
}
function calcola() {
var ss = 0.0;
//
if (document.getElementById("contrassegno").checked == true){
if (document.getElementById("corriere").checked == true){
ss = 13.0;
}
if (document.getElementById("poste").checked == true){
ss = 4.5;
}
}
if (document.getElementById("carta").checked == true || document.getElementById("conto").checked == true){
if (document.getElementById("corriere").checked == true){
ss = 9.5;
}
if (document.getElementById("poste").checked == true){
ss = 2.0;
}
}
if (document.getElementById("ritiro").checked == true){
ss = 0.0;
}
document.getElementById("ss").value = ss;
document.getElementById("ss1").value = ss;
document.getElementById("totaless").value = ss + parseFloat(document.getElementById("totale").value);
}
function sblocca(){
document.getElementById("corriere").disabled = false;
document.getElementById("poste").disabled = false;
calcola();
if (document.getElementById("carta").checked == true)
{
document.getElementById("ccTable").style.visibility = "visible";
document.getElementById("ccTable").style.display = "inline";
}
else
{
document.getElementById("ccTable").style.visibility = "hidden";
document.getElementById("ccTable").style.display = "none";
//
document.getElementById("ccNumero").value='';
document.getElementById("ccTitolare").value='';
document.getElementById("ccMese").value='';
document.getElementById("ccAnno").value='';
}
}
function blocca(){
document.getElementById("corriere").disabled = true;
document.getElementById("poste").disabled = true;
calcola();
}
</script>
<form name="ordina" action="carrelloeng.jsp" method="post" id="ordina">
<tr>
<td rowspan="3" align="left" valign="top">
Method of payment:</p>
<div align="center" class="invisibile" id="ccTable">
<table width="380" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="74" class="normale"><div align="right">Owner</div></td>
<td width="306"><input name="ccTitolare" type="text" id="ccTitolare" size="35"></td>
</tr>
<tr>
<td class="normale"><div align="right">Card Number</div></td>
<td><input name="ccNumero" type="text" id="ccNumero" size="35"></td>
</tr>
<tr>
<td class="normale"><div align="right">Expiration date </div></td>
<td>
<select name = "ccMese" id ="ccMese">
<option></option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select name = "ccAnno" id ="ccAnno">
<option></option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>12</option>
</select>
/
(mese/anno) </p></td>
</tr>
<tr>
<td class="normale"><div align="right">Type</div></td>
<td class="normale"><input name="ccTipo" type="radio" value="Mastercard" id="ccVisa">
MasterCard
<input name="ccTipo" type="radio" value="Visa" id="ccMastercard">
Visa </td>
</tr>
<tr>
<td class="normale"></td>
<td class="normale">Using a credit card will insure that your order will be processed at time of delivery. </td>
</tr>
</table>
</div>
<input name="ModPag" type="radio" value="Credit Card" id="carta" onClick="javascript:sblocca();">
Credit Card
<input name="ModPag" type="radio" value="Payment on delivery" id="contrassegno" onClick="javascript:sblocca();">
Payment on delivery
<input name="ModPag" type="radio" value="Bank transfer " id="conto" onClick="javascript:sblocca();">
Bank transfer
<input name="ModPag" type="radio" value="Bookshop pick-up" id="ritiro" onClick="javascript:blocca();">
Bookshop pick-up </p>
</p>
Method of shipping:</p>
<input name="ModSpe" type="radio" value="Express Courier" disabled="disabled" id="corriere" onclick="javascript:calcola();">
Express Courier
<input name="ModSpe" type="radio" value="Poste Italiane" disabled="disabled" id="poste" onclick="javascript:calcola();">
Poste Italiane
</p>
</p>
<input type="checkbox" name="accetto" value="accetto" id="accetto">
Select to approve general conditions (necessary to go ahead with the order) and time of shipping.
</p></td>
<td height="100" align="right" valign="bottom"><input type="hidden" name="Ordina" value="si">
</td>
<td align="left" valign="bottom">
€.
<input type="hidden" id="totale" value="<%=df.format(totale)%>"><%= df.format(totale) %>
<span class="piccoloNormale">(cost of books) </span></p></td>
</tr>
<tr>
<td height="50" rowspan="2" align="right" valign="top">
</p> </td>
<td align="left" valign="top">
</p>
€.
<input type="text" disabled="disabled" id="ss1" value="0" size="4" name="ss1">
<input type="hidden" id="ss" value="0" size="4" name="ss">
<span class="piccoloNormale">(shipping cost)</span></p>
€. <input type="text" disabled="disabled" id="totaless" value="<%= totale %>" size="4">
<span class="piccoloNormale">(total)</span></p> </td>
</tr>
<tr>
<td align="left" valign="bottom">
<input name="button2" type="button" class="BottoneArancione80" onClick="javascript:checkOrdine();" value="Order">
<span class="piccoloGrigino">(you will not allowed to change your order)</span> </td>
</tr>
</form>
Quello che vorrei fare è modificare le impostazioni in base al luogo della spedizione. Cioè vorrei applicare un costrutto switch, che in base al fatto che l'ordine venga dall'Italia resti inalterato. Se dall'Europa o dal resto del mondo mi abiliti solo il pagamento con Carta di Credito, chiaramente con spese di spedizione diverse.
Riuscite ad aiutarmi?
Grazie