get the button name with document.getElementById
hi,
i want to develop a script on that i only have to set the names like this :
-
<button name="1" id="url" onclick="myFunction()">1</button>
<button name="2" id="url" onclick="myFunction()">2</button>
<button name="3" id="url" onclick="myFunction()">3</button>
<script>
function myFunction() {
var $x = document.getElementById("url").getAttribute("name");
$.post("worker.php",
{
Page: $x
},
function(data){
$("#content1").html(data);
}
);
}
</script>
the Problem is : only the first button works and give me the contend back the others give me the first contend
i want one global function that can read (or get ?) a parameter to post to my worker.php script
in worker.php is only the line e.g.
- echo $_post[page];
to echo the Post parameter from 'Page'
but it always give 1 back
ps : sry 4 my english