Red de conocimiento de recetas - Recetas completas - Calcular el precio total de la fruta usando javascript

Calcular el precio total de la fruta usando javascript

& ltForm& gt

& ltselect name = " select " & gt

& ltoption value="0 " >Por favor seleccione

& ltoption value=" 1 " >Manzana Pera Plátano;

& lt/select & gt;

& ltbr/>;

Precio unitario:< input size = " 10 " name = " var 1 " contenido editable = " false "/& gt;

& ltbr/>;

Cantidad:

& ltbr/>;

& ltbr/> p>

Precio total:< input size="20" name="var3"/>

& ltbr/>;

& ltinput type = " botón " valor = " cálculo " nombre = " recuento "/& gt;

& ltinput type="reset"/>

& lt/form & gt;

& ltscript>

documento formularios[0]. seleccione .onchange = function(){

var formulario = documento formularios[0];

p>

if(form.select.value==1)

{

formulario var 1 .5; p>

else if(form.select.value==2){

formulario var 1 valor = 3.5;

}

else. if (form.select .value==3) {

form.var1.value=4.5

}

}

documento . formularios[0] . var 2 . onblur = function(){

if(este . valor == " " | | este . valor == nulo)

{

f 1 . tamaño de fuente = " 13px ";

F1.innerHTML = "¡Ingrese la cantidad! ";

Regresar;

}

var patrn=/^[1-9]{1}\d*$/;

var s = this.value

if (!patrn.exec)

{

f 1 tamaño de fuente = " 13px ";

F1.innerHTML= "¡Ingrese el número correcto! ";

}

}

documento. formularios[0]. recuento. onclick = función(){

var formulario = documento . formularios[0];

if(formulario . var 1 . valor == null | | formulario . var 1 . valor == " ")

{

Alert("¡Seleccione la fruta que desea comprar!");

Return;

}

if(form . var 2 . value = =nu

ll | | formulario . var 2 . valor = = " ")

{

Alerta("¡Ingrese la cantidad!");

Regresar;

p>

}

var patrn=/^[1-9]{1}\d*$/;

var s = formulario . var 2 . valor;

If (!patrn.exec)

{

Alerta ("¡Ingrese el número correcto!");

Retorno;

}

var resultado = parse float(form . var 1 . value)* parse float(form . var 2 . value);

formulario .var 3 . valor = resultado;

}

& lt/script & gt;