There is a function:

function UserPaga() { alert(number); } 

Here is the code that calls it:

<div onClick = 'UserPaga ();'> </ div>

it is necessary that when pressed, not only the function is started but the variable number is transferred there! How to make it?

  • one
    Read JavaScript documentation .. I don’t see any other way to solve this problem - Photon

2 answers 2

The function is written variable, which is passed:

 function UserPaga(number) { alert(number); } 

When a function is called, the value of the variable to be passed is written:

 UserPaga(999); 

The result is the following html code:

 <script> function UserPaga(number) { alert(number); // 999 } </script> <div onClick='UserPaga(999);'></div> 
  • Thanks, I just thought so and just wrote like this: <script> function UserPaga (number) {alert (number); // 999} </ script> <div onClick = 'UserPaga (var number = "999");'> </ div> - Kirpich643
 <div onClick='UserPaga(999);'></div> function UserPaga(number) { alert(number); // 999 }