Convertisseur de plus de 30 monnaie.

Soyez le premier à donner votre avis sur cette source.

Snippet vu 13 968 fois - Téléchargée 29 fois

Contenu du snippet

J'ai fais ce script après une grande dépression lol.jai tout fais moi même et voila si ca peut vous aider allez y!

Source / Exemple :


<HTML>
<HEAD>

</HEAD>

</HEAD>
<BODY text="blue">
<table border="1" bordercolor="#6699FF" cellspacing="0" cellpadding="0" ><tr valign="top"><td colspan="2" align="center">
<FORM method=POST>

<!--<TR>
<TD>
<a href="http://fxtop.com/fr/rt.php3" target="_top"><FONT SIZE="-1">Temps réel</FONT></a>
</TD>
</TR>-->

<script language="Javascript">
<!--

function fPriceSite(aSTRIsoCurr1, aSTRIsoCurr2, aPrecision, aSite)
{
	return("<A HREF="+aSite+"?C1="+aSTRIsoCurr1+"&C2="+aSTRIsoCurr2+" target=_top>1 "+aSTRIsoCurr1+"="+fPrice(aSTRIsoCurr1, aSTRIsoCurr2, aPrecision)+" "+aSTRIsoCurr2+"</A>");
}

function mkMajorRates(aSite)
{
	document.write("<FONT SIZE=-1>"+fPriceSite( "EUR", "USD", 4, aSite)+"<BR>"+fPriceSite( "EUR", "GBP", 4, aSite)+"<BR>"+fPriceSite( "USD", "FRF", 4, aSite)+"<BR>"+fPriceSite( "EUR", "JPY", 2, aSite)+"<BR>"+fPriceSite( "USD", "JPY", 2, aSite)+"<BR>"+fPriceSite( "USD", "CHF", 4, aSite)+"<BR>"+fPriceSite( "GBP", "USD", 4, aSite)+"<BR>"+fPriceSite( "USD", "CAD", 4, aSite)+"<BR>"+fPriceSite( "USD", "AUD", 4, aSite)+"<BR>"+fPriceSite( "EUR", "CHF", 4, aSite)+"</FONT>");
}

document.write("");
document.write("");
mkMajorRates("");
document.write("");

//-->
</SCRIPT>

<INPUT TYPE="button"
VALUE="Calculez" onclick="convertform(this.form)">
<INPUT TYPE="button"  VALUE="Effacez"
onclick="clearform(this.form)"></td></tr>

<tr valign="top"><td align="center">
<table border="1" bordercolor="#6699FF"><tr>
<td>EUR euro</td><td>   
1</td><td><INPUT TYPE=TEXT NAME=val1 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,0)"></td></tr>

<tr> 
<td>FRF franc français</td><td>
6.55957</td><td><INPUT TYPE=TEXT NAME=val2 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,1)"></td></tr>

<tr>
<td>DEM mark allemand</td><td>
1.95583</td><td><INPUT TYPE=TEXT NAME=val3 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,2)"></td></tr>

<tr>
<td>ATS sch. autrichien</td><td>
13.7603</td><td><INPUT TYPE=TEXT NAME=val4 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,3)"></td></tr>

<tr>
<td>BEF/LUF franc belge/lux</td><td>
40.3399</td><td><INPUT TYPE=TEXT NAME=val5 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,4)"></td></tr>

<tr>
<td>ESP pes. espagnole</td><td>
166.386</td><td><INPUT TYPE=TEXT NAME=val6 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,5)"></td></tr>

<tr>
<td>ITL lire italienne</td><td>
1936.27</td><td><INPUT TYPE=TEXT NAME=val7 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,6)"></td></tr>

<tr>
<td>IEP livre irlandaise</td><td>
0.787564</td><td><INPUT TYPE=TEXT NAME=val8 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,7)"></td></tr>

<tr>
<td>NLG fl. hollandais</td><td>
2.20371</td><td><INPUT TYPE=TEXT NAME=val9 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,8)"></td></tr>

<tr>
<td>PTE esc. portugais</td><td>
200.482</td><td><INPUT TYPE=TEXT NAME=val10 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,9)"></td></tr>

</table></td></td><td align="center"><table border="1" bordercolor="#6699FF">
<tr>
<td>FIM mark finlandais</td><td>
5.94573</td><td><INPUT TYPE=TEXT NAME=val11 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,10)"></tr>
<tr>
<td>GRD drachme grec</td><td>
340.750</td><td><INPUT TYPE=TEXT NAME=val12 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,11)"></td></tr><tr>

<td>USD dollar américain</td><td>

<INPUT TYPE=TEXT NAME=factor13 SIZE=7></td><td><INPUT TYPE=TEXT NAME=val13 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,12)"></td></tr><tr>

<td>AUD dol. australien</td><td>

<INPUT TYPE=TEXT NAME=factor14 SIZE=7></td><td><INPUT TYPE=TEXT NAME=val14 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,13)"></td></tr><tr>

<td>GBP livre sterling</td><td>

<INPUT TYPE=TEXT NAME=factor15 SIZE=7></td><td><INPUT TYPE=TEXT NAME=val15 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,14)"></td></tr><tr>

<td>CHF franc suisse</td><td>

<INPUT TYPE=TEXT NAME=factor16 SIZE=7></td><td><INPUT TYPE=TEXT NAME=val16 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,15)"></td></tr><tr>

<td>JPY yen japonais</td><td>

<INPUT TYPE=TEXT NAME=factor17 SIZE=7></td><td><INPUT TYPE=TEXT NAME=val17 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,16)"></td></tr><tr>

<td>CAD dol. canadien</td><td>

<INPUT TYPE=TEXT NAME=factor18 SIZE=7></td><td><INPUT TYPE=TEXT NAME=val18 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,17)"></td></tr><tr>

<td><select name="optcurr1"  onchange="selectopt(this.form,1)">
<option value="ARS">ARS Argentine</option>
<option value="BGL">BGL Bulgarie</option>
<option value="BRL">BRL Brésil</option>
<option value="CLP">CLP Chili</option>
<option value="CYP">CYP Chypre</option>
<option value="CZK">CZK Tchéquie</option>
<option selected value="DKK">DKK Danemark</option>
<option value="EEK">EEK Estonie</option>
<option value="EGP">EGP Egypte</option>
<option value="HKD">HKD Hong-Kong</option>
<option value="HUF">HUF Hongrie</option>
<option value="IDR">IDR Indonésie</option>
<option value="ISK">ISK Islande</option>
<option value="MTL">MTL Malte</option>
<option value="MXN">MXN Mexique</option>
<option value="MYR">MYR Malaisie</option>
<option value="NOK">NOK Norvège</option>
<option value="NZD">NZD N-Zélande</option>
<option value="PLN">PLN Pologne</option>
<option value="SEK">SEK Suède</option>
<option value="SGD">SGD Singapour</option>
<option value="SIT">SIT Slovénie</option>
<option value="THB">THB Thailande</option>
<option value="VEB">VEB Vénézuela</option>
<option value="ZAR">ZAR Afrique S.</option>
</select></td>
<td><INPUT TYPE=TEXT NAME=factor19 SIZE=7></td>
<td>

<INPUT TYPE=TEXT NAME=val19 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,18)"></td></tr><tr>

<td><select name="optcurr2" onchange="selectopt(this.form,2)">
<option value="ARS">ARS Argentine</option>
<option value="BGL">BGL Bulgarie</option>
<option value="BRL">BRL Brésil</option>
<option value="CLP">CLP Chili</option>
<option value="CYP">CYP Chypre</option>
<option value="CZK">CZK Tchéquie</option>
<option value="DKK">DKK Danemark</option>
<option value="EEK">EEK Estonie</option>
<option value="EGP">EGP Egypte</option>
<option value="HKD">HKD Hong-Kong</option>
<option value="HUF">HUF Hongrie</option>
<option value="IDR">IDR Indonésie</option>
<option value="ISK">ISK Islande</option>
<option value="MTL">MTL Malte</option>
<option value="MXN">MXN Mexique</option>
<option value="MYR">MYR Malaisie</option>
<option value="NOK">NOK Norvège</option>
<option value="NZD">NZD N-Zélande</option>
<option value="PLN">PLN Pologne</option>
<option selected value="SEK">SEK Suède</option>
<option value="SGD">SGD Singapour</option>
<option value="SIT">SIT Slovénie</option>
<option value="THB">THB Thailande</option>
<option value="VEB">VEB Vénézuela</option>
<option value="ZAR">ZAR Afrique S.</option>
</select></td>
<td>

<INPUT TYPE=TEXT NAME=factor20 SIZE=7></td>
<td>

<INPUT TYPE=TEXT NAME=val20 SIZE=13 VALUE=""
onfocus="focusvalue(this.form,19)"></td></tr></table>
</td></tr><tr><td colspan="2" align="center">
<INPUT TYPE="button"
VALUE="Réinitialiser les taux de change" onclick="resetform(this.form)">

<SCRIPT LANGUAGE="JavaScript">

<!-- Author & Copyright 1997-1999 : Laurent PELE (webmaster@fxtop.com , http://www.pele.org) -->

document.forms[0].count = 20;  // number of unit types
document.forms[0].rsize = 15;  // Rounding size, use same as SIZE
document.forms[0].focus = 0;	  // input on euro by default

function initcours()
{
document.forms[0].factor1 = 1;	  // EUR to EUR.
document.forms[0].nbdec1 = 2;

document.forms[0].factor2 = 6.55957;  // EUR to FRF.
document.forms[0].nbdec2 = 2;

document.forms[0].factor3 = 1.95583;  // EUR to DEM.
document.forms[0].nbdec3 = 2;

document.forms[0].factor4 = 13.7603;  // EUR to ATS.
document.forms[0].nbdec4 = 2;

document.forms[0].factor5 = 40.3399; // EUR to BEF or LUF
document.forms[0].nbdec5 = 0;

document.forms[0].factor6 = 166.386; // EUR to ESP.
document.forms[0].nbdec6 = 0;

document.forms[0].factor7 = 1936.27;   // EUR to ITL.
document.forms[0].nbdec7 = 0;

document.forms[0].factor8 = 0.787564;	// EUR to IEP.
document.forms[0].nbdec8 = 2;

document.forms[0].factor9 = 2.20371; // EUR to NLG.
document.forms[0].nbdec9 = 2;

document.forms[0].factor10 = 200.482; // EUR to PTE.
document.forms[0].nbdec10 = 0;

document.forms[0].factor11 = 5.94573; // EUR to FIM.
document.forms[0].nbdec11 = 2;

document.forms[0].factor12 = 340.75; // EUR to GRD
document.forms[0].nbdec12 = 0;

// Out currencies, batch updated
document.forms[0].factor13.value = 1.23440000; // EUR to USD.
document.forms[0].nbdec13 = 2;

document.forms[0].factor14.value = 1.64990000; // EUR to AUD.
document.forms[0].nbdec14 = 2;

document.forms[0].factor15.value = .67350000; // EUR to GBP.
document.forms[0].nbdec15 = 2;

document.forms[0].factor16.value = 1.55870000; // EUR to CHF.
document.forms[0].nbdec16 = 2;

document.forms[0].factor17.value = 132.000000; // EUR to JPY.
document.forms[0].nbdec17 = 0;

document.forms[0].factor18.value = 1.64280000; // EUR to CAD.
document.forms[0].nbdec18 = 2;

// optional currencies values :

AffectValue(1, document.forms[0].optcurr1.selectedIndex);
AffectValue(2, document.forms[0].optcurr2.selectedIndex);
}

function AffectValue(aopt, astrcurr)
{
	var lfactor=1;
	var lnbdec=2;

	// switch does not work with some browsers
	if (astrcurr ==6)
	{
		lfactor = 7.44700000; // EUR to DKK .
		lnbdec = 2;
	}
	else
	{
		if (astrcurr ==8)
		{
			lfactor = 7.75571849; // EUR to EGP .
			lnbdec = 2;
		}
		else
		{
			if (astrcurr ==0)
			{
				lfactor = 3.63491834; // EUR to ARS .
				lnbdec = 2;
			}

			if (astrcurr ==1)
			{
				lfactor = 2.12603774; // EUR to BGL .
				lnbdec = 0;
			}

			if (astrcurr ==2)
			{
				lfactor = 3.57615691; // EUR to BRL .
				lnbdec = 2;
			}
			if (astrcurr ==3)
			{
				lfactor = 739.396969; // EUR to CLP .
				lnbdec = 0;
			}

			if (astrcurr ==4)
			{
				lfactor = .58599000; // EUR to CYP .
				lnbdec = 2;
			}

			if (astrcurr ==5)
			{
				lfactor = 33.2100000; // EUR to CZK .
				lnbdec = 2;
			}

			if (astrcurr ==7)
			{
				lfactor = 15.6466000; // EUR to EEK .
				lnbdec = 2;
			}

			if (astrcurr ==9)
			{
				lfactor = 9.61890000; // EUR to HKD .
				lnbdec = 2;
			}

			if (astrcurr ==10)
			{
				lfactor = 253.560000; // EUR to HUF .
				lnbdec = 0;
			}

			if (astrcurr ==11)
			{
				lfactor = 10475.3445; // EUR to IDR .
				lnbdec = 0;
			}

			if (astrcurr ==12)
			{
				lfactor = 87.2400000; // EUR to ISK .
				lnbdec = 2;
			}

			if (astrcurr ==13)
			{
				lfactor = .42710000; // EUR to MTL .
				lnbdec = 2;
			}

			if (astrcurr ==14)
			{
				lfactor = 13.5505293; // EUR to MXN .
				lnbdec = 2;
			}

			if (astrcurr ==15)
			{
				lfactor = 4.71808467; // EUR to MYR .
				lnbdec = 2;
			}

			if (astrcurr ==16)
			{
				lfactor = 8.51500000; // EUR to NOK .
				lnbdec = 2;
			}

			if (astrcurr ==17)
			{
				lfactor = 1.88410000; // EUR to NZD .
				lnbdec = 2;
			}

			if (astrcurr ==18)
			{
				lfactor = 4.72000000; // EUR to PLN .
				lnbdec = 2;
			}

			if (astrcurr ==19)
			{
				lfactor = 9.27130000; // EUR to SEK .
				lnbdec = 2;
			}

			if (astrcurr ==20)
			{
				lfactor = 2.08790000; // EUR to SGD .
				lnbdec = 2;
			}

			if (astrcurr ==21)
			{
				lfactor = 238.040000; // EUR to SIT .
				lnbdec = 0;
			}

			if (astrcurr ==22)
			{
				lfactor = 48.6591825; // EUR to THB .
				lnbdec = 2;
			}

			if (astrcurr ==23)
			{
				lfactor = 2380.57785; // EUR to VEB .
				lnbdec = 0;
			}
			if (astrcurr ==24)
			{
				lfactor = 8.19950000; // EUR to ZAR .
				lnbdec = 2;
			}

		}
	}

	if (aopt ==1)
	{
		document.forms[0].factor19.value = lfactor; // EUR to curropt1 .
		document.forms[0].nbdec19 = lnbdec;
	}

	if (aopt ==2)
	{
		document.forms[0].factor20.value = lfactor; // EUR to curropt2.
		document.forms[0].nbdec20 = lnbdec;
	}
}

function selectopt(aform, aoptioncurrency)
{
	var lcurr;
	if (aoptioncurrency==1)
	{
		lcurr=document.forms[0].optcurr1.selectedIndex;
	}
	else
	{
		lcurr=document.forms[0].optcurr2.selectedIndex;
	}

		AffectValue(aoptioncurrency, lcurr);
		convertform(aform);
}

function resetform(form)
{
	clearform(form);
	initcours();
}

function initopt(aForm)
{
	document.forms[0].optcurr1.selectedindex=6;
	document.forms[0].optcurr2.selectedindex=19;

	AffectValue(1, 6);
	AffectValue(2, 19);
}

initopt(document.forms[0]);
initcours();

function convertform(form)
{
	var firstvalue3 = 0;
	var firstvalue2 = 0;
	var firstvalueN = 0;
	var firstIndex = 0;
	var lvalue=0;
	var lfactor=0;

	if (form.focus!="" && form.focus>=0)
	{
		firstIndex=form.focus+1;

		if (firstIndex>0 && firstIndex<=form.count )
		{
			lvalue=form["val"+firstIndex].value;

			if (lvalue!="" && lvalue.length !=0)
			{
				lvalue=litvirgule(lvalue);

				if (firstIndex>=13)
				{
					lfactor=form["factor"+firstIndex].value;
					lfactor=litvirgule(lfactor);
				}
				else
				{
					lfactor=form["factor"+firstIndex];
				}

				firstvalueN=lvalue/lfactor;
				firstvalue3 = Math.round (firstvalueN * 1000)/1000;
				firstvalue2 = Math.round (firstvalueN * 100)/100;
			}
		}
	}

	if (firstvalue3==0)
	{
		// for Macintosh (onfocus function has special behaviour)
		for (var i = 1; i < form.count+1; i++)
		{
			// Find first non-blank entry
			lvalue=form["val"+i].value;

			if (lvalue != "" && lvalue.length !=0)
			{
				lvalue=litvirgule(lvalue);

				if (lvalue !=0 )
				{
					if (i>=13)
					{
						lfactor=form["factor"+i].value;
						lfactor=litvirgule(lfactor);
					}
					else
					{
						lfactor=form["factor"+i];
					}

					firstvalueN=lvalue/lfactor;
					firstvalue3 = Math.round (firstvalueN * 1000)/1000;
					firstvalue2 = Math.round (firstvalueN * 100)/100;

					firstIndex=i;

					break;
				}
			}
		}
	}

	if (firstvalue3 == 0)
	{
		clearform(form);
		return false;
	}

	form.val1.value = formatvalue(firstvalue2, form.rsize, form.nbdec1);

	for (var i = 2; i < form.count+1; i++)
	{
		if (i>=13)
		{
			lfactor=form["factor"+i].value;
			lfactor=litvirgule(lfactor);
		}
		else
		{
			lfactor=form["factor"+i];
		}

		if (i!=firstIndex)
		{
			if (firstIndex<13)
			{
				if (i<13)
				{
					form["val"+i].value = formatvalue((firstvalue3 *
						lfactor), form.rsize, form["nbdec"+i]);
				}
				else
				{
					form["val"+i].value = formatvalue((firstvalue2 *
					lfactor), form.rsize, form["nbdec"+i]);
				}
			}
			else
			{
				if (i<13)
				{
					form["val"+i].value = formatvalue((firstvalue2 *
						lfactor), form.rsize, form["nbdec"+i]);
				}
				else
				{
					form["val"+i].value = formatvalue((firstvalueN *
						lfactor), form.rsize, form["nbdec"+i]);
				}
			}
		}
		else
		{
		  form["val"+i].value = formatvalue(lvalue, form.rsize, form["nbdec"+i]);
		}
	}

	return true;
}

function litvirgule(ChaineNombre)
{
	// retire les espaces et transforme les points en virgule !
	var i=0;
	var lyapoint=0;
	var lChaine=ChaineNombre;
	while (i<eval(lChaine.length))
	{
		if (lChaine.charAt(i)==","  || lChaine.charAt(i)==".")
		{
			if (lyapoint>0)
			{
				lChaine=lChaine.substring(0,i)+lChaine.substring(i+1,lChaine.length);
				i--;
			}
			else
			{
				lChaine=lChaine.substring(0,i)+"."+lChaine.substring(i+1,lChaine.length);
			}
			lyapoint=1;
		}
		else
		{
			if (lChaine.charAt(i)==" ")
			{
				lChaine=lChaine.substring(0,i)+lChaine.substring(i+1,lChaine.length);
				i--;
			}
		}

		i++;
	}
	return lChaine;
}

function formatvalue(input, rsize, precision)
{
	var invalid = "**************************";
	var nines = "999999999999999999999999";
	var NbArrondi = Math.round(input * Math.pow (10,precision)+0.0000001) / Math.pow(10,precision);

	var chaine = "" + NbArrondi;
	var nombre = parseFloat(chaine);
	var lnChaine=0;

	if (chaine.indexOf("e") != -1 ||  nombre > parseFloat(nines.substring(0,rsize)+".4"))
		return invalid.substring(0, rsize);

	var rounded = "" + (nombre + (nombre - parseFloat(chaine.substring(0,rsize))));

	var length = rounded.indexOf (".")

	if (length == -1)
	{
		// ajout espace(s) séparateur de milliers
		lnChaine=rounded.length;
		while (lnChaine>=4)
		{
			rounded=rounded.substring(0, lnChaine-3)+" "+rounded.substring(lnChaine-3,rounded.length)
			lnChaine=lnChaine-3
		}

		return rounded
	}
	else
	{
		// ajout espace(s) séparateur de milliers
		lnChaine=length;
		if (precision > 0)
		{
			length = length + precision + 1
		}

		// ajout espace(s) séparateur de milliers
		while (lnChaine>=4)
		{
			rounded=rounded.substring(0, lnChaine-3)+" "+rounded.substring(lnChaine-3,rounded.length)
			lnChaine=lnChaine-3
			length = length + 1
		}

		return rounded.substring(0, length)
	};
}

function clearform(form)
{
	for (var i = 1; i < form.count+1; i++) form["val"+i].value = "";
	return true;
}

function clearnothing(form)
{
	return true;
}

function focusvalue(form, input)
{
	form.focus = input;
	return true;
}

</SCRIPT>
</tr></table></FORM>
</BODY>

</HTML>

Conclusion :


Si ya des bogs écrivez moi.

A voir également

Ajouter un commentaire

Commentaires

il ne fait plus les vrais taux
Messages postés
14855
Date d'inscription
mardi 11 mars 2003
Statut
Contributeur
Dernière intervention
11 octobre 2020
444 > antony333
BONJOUR si si la politesse c'est bien aussi.
les taux sont écrits en durs dans le code, donc même le lendemain de la dépose de ce source, ils n'étaient plus valables.... Et il date de 2004....
Messages postés
164
Date d'inscription
jeudi 23 octobre 2003
Statut
Membre
Dernière intervention
25 août 2008

je sais que le code est long a mourrir mais si vous voulez le décortiquer c'est a vous.Laissez vos commentaires ou autre mots stp
Kev

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.