Reputation: 11
Why this script cannot send the value in the button with onclick action simple javascript
<input type="submit" onclick="(document.getElementById('act').value='delete_user')&&(document.getElementById('uid').value='1')" >
But this script worked
<input type="submit" onclick="(document.getElementById('act').value='delete_user')>
How make both values get work ?
Upvotes: 0
Views: 468
Reputation: 3813
You are using &&, which is used for validation purpose.
Correct code is :
<input type="submit" onclick="document.getElementById('act').value='delete_user';document.getElementById('uid').value='1'" >
Upvotes: 0
Reputation: 2579
Use this in the html
<input type="submit" onclick="my_function();">
and add in the javascript part:
function my_function(){
document.getElementById('act').value='delete_user';
document.getElementById('uid').value='1';
}
Upvotes: 0
Reputation: 3996
This should work:
<input type="submit" onclick="document.getElementById('act').value='delete_user';document.getElementById('uid').value='1'; " >
If it does not, please check if there is an input with id (not name) uid
and that the following also works.
<input type="submit" onclick="document.getElementById('uid').value='1'; " >
Check it out here:
Upvotes: 1