dimanche 1 mars 2015

Define parameters to be used in a web page as an input


I'm trying to submit two parameters to be used in a javascript function. The code is as follows:



<!DOCTYPE html>
<html>
<head>
<script src="proj4js/lib/proj4js/lib/proj4js-compressed.js"></script>

</head>
<body>


<script>
function func1 (x,y){

var z=x+y
alert(z)

}

</script>
<form >
first input:<br>
<input type="text" y="Y" value=85>
<br>
second input:<br>
<input type="text" x="X" value=15>
<br><br>
<input type="submit" value="Submit">
</form>

<button type="button" onclick="func1(x,y)">Try it</button>


The error I get is Uncaught ReferenceError: x is not defined How should I define x and y as an input to be put in js function?





Aucun commentaire:

Enregistrer un commentaire