Probleme de bouton en image (calc)

JS -  
 JS -
Bonjour,
J'ai un probleme avec ce script de calculatrice en JS qui marche très bien lorsque les boutons sont des input type="submit" mais une fois que j'introduit les boutons en jpg crées, cela initialise à chaque fois l'affichage et la calculatrice ne sert donc plus à rien.
Comment y remedier ? merci d'avance

voici le code HTML:

<body onLoad="Init();"> 

        [....]

	<table id="Calculatrice" border="1" cellpadding="0" cellspacing="0">
	<form  name="calculatrice">
	<tr>
		<td>
			<table border=0>
			<tr>
				<td colspan=8>
					<input  type="text" name="affichage">
				</td>
			</tr>
			<tr>
				<td>
					<input type="image" alt="" src="Modules/images/boutons/1024px/key_07.jpg"  name=but7 value=" 7 " onClick="NumPress(this);" >
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_08.jpg"  name=but8 value=" 8 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_09.jpg" name=but9 value=" 9 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_div.jpg" name=div value=" / " onClick="OpPress(this);">
				</td>

			</tr>
			<tr>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_04.jpg" name=but4 value=" 4 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_05.jpg" name=but5 value=" 5 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_06.jpg" name=but6 value=" 6 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_mult.jpg" name=prod value=" * " onClick="OpPress(this);">
				</td>
			</tr>
			
			<tr>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_01.jpg" name=but1 value=" 1 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_02.jpg" name=but2 value=" 2 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_03.jpg" name=but3 value=" 3 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_moins.jpg" name=moins value=" - " onClick="OpPress(this);">
				</td>

			</tr>
			<tr>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_00.jpg" name=but0 value=" 0 " onClick="NumPress(this);">
				</td>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_07.jpg" name=dot value=" . " onClick="DotPress();">
				</td>
				
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_c.jpg" name=clear value=" C " onClick="Clear();">
				</td>

				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_plus.jpg" name=plus value=" + " onClick="OpPress(this);">
				</td>
				
			</tr>
			
			<tr>
				<td>
					<input type="image" src="Modules/images/boutons/1024px/key_eq.jpg" name=enter value=" = " onClick="Calculate();">
				</td>		
			</tr>
	
			</table>
		</td>
	</tr>
	</form>	
	</table>

---------------------------------------------------------------------------------------------------------------
et le code JS:

var MyForm;
var Aff="";
var Calc="";
var IsOpPressable=false;
var IsDotPressable=true;
var HasCalculate=false;

function NumPress(touche){
	if(!IsOpPressable || HasCalculate){
		Aff="";
		HasCalculate=false;
		IsDotPressable=true;
	}
	Aff+=parseInt(touche.value);
	IsOpPressable=true;
	Refresh();
}

function OpPress(touche){
	if(IsOpPressable){
		Calc+=Aff + touche.value;
		Aff=touche.value;
		IsOpPressable=false;
	}
	Refresh();
}


function Calculate(){
	Calc+=Aff;
	Aff=eval(Calc);
	Calc="";
	IsOpPressable=true;
	HasCalculate=true;
	Refresh();
}


function Refresh(){
	MyForm.affichage.value=Aff;
}


function DotPress(){
	if(IsDotPressable){
		Aff+=".";
		IsDotPressable=false;
	}
	Refresh();
}


function Init(){
	MyForm=document.forms["calculatrice"];
}

function Trans(touche){
	Aff=eval("Math." + touche.name + "(" + parseInt(Aff) + ");");
	HasCalculate=true;
	Refresh();
}


function Convert(base){
	Aff=(new Number(Aff)).toString(base);
	HasCalculate=true;
	Refresh();
}



function Clear(){
	Aff="";
	Refresh();
}


6 réponses

JS
 
J'ai besoin d'aide svp...
0
JS
 
.
0
JS
 
up
0
JS
 
.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
JS
 
.
0
JS
 
Up
0