I am writing a script where I provide two buttons “Grant” and “Revoke” to the user. The problem is that both of them are set and “Grant” button always takes precedence.
Below is Sample code
<form name="form_access" id="form_access" action="" method="POST" class="access">
|
|
|
<input type="hidden" name="accessaction" value="Grant Access"/>
<input type="hidden" name="revokeaction" value="Revoke Access"/>
<a id="_access_btt" class="button" href="#">Grant Access</a>
<img class="ajaxload" style="display:none;" id="ajaxld" src="images/ajax-loader.gif"/>
<a id="_revoke_btt" class="button" href="#">Revoke Access</a>
<img class="ajaxload" style="display:none;" id="ajaxld1" src="images/ajax-loader.gif"/>
</form>
Rather than using two hidden elements, Why dont you use a single hidden element, something like this?
for example: you could use:
and depending upon what button user clicks, with the help of javascript you could set this action’s value too:
and
and then submit the form!
so in the end, you can just check value $_REQUEST[‘accessPermission’] in your PHP,
and you will get whatever value you have set for your hidden form element accessPermission:
if its value is Revoke Access you will get $_REQUEST[‘accessPermission’] as ‘Revoke Access’
if its value is Grant Access you will get $_REQUEST[‘accessPermission’] as ‘Grant Access’
So at the end, you can construct your form as:
And Both the values are set because, its really specifically set by the lines:
Grant Action takes precedence, because that’s appears first.