Thread: how to pass values in javascript?
i can call function <body> in javascript, can pass values function? check this.....if want send values, tried din't work....php code:
<html>
<head>
<title>
mul table
</title>
</head>
<script language="javascript">
function abhimul() {
var abhi=prompt("enter a number");
document.write("you entered " +abhi+ "<br>");
for(var i=1; i<=10; i++)
{
document.write(abhi +" * " + i + "=" +(i*abhi)+ "<br>");
}
}
</script>
<body>
<a href="javascript:abhimul()">know tables</a>
</body>
</html>
in called function, can recieve abhimul(var abhi) ?php code:
<body>
var abhi=prompt("enter a number");
document.write("you entered " +abhi+ "<br>");
abhimul(abhi);
</body>
how pass values?
you try use javascript without script tags in body of html page. not going work.
example guess want user enter number , let javascript use given number.
javascript functions can have parameters so:
now can call javascript function way did in first example, 2 parameters.code:<script type="text/javascript"> function test(param1, param2) { alert( param1 +' '+ param2 ); } </script>
result in alert message "test param1 test param2'
so guess want:code:<a href="javascript:test('test param1', 'test param2')">link</a>
then html body create link calling "asknumber" function same way did in first example.code:<script type="text/javascript"> function asknumber() { var number = prompt("enter number"); alertnumber( number ); } function alertnumber( number ) { alert( number ); } </script>
more on javascript function: http://www.w3schools.com/js/js_functions.asp
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] how to pass values in javascript?
Ubuntu
Comments
Post a Comment