php - Using a hyperlink to submit a form instead of a button through an intermedite function is not working -
i want submit form through 'edit(param1,param2)' function in turn being called in either of 2 ways..
echo '<input type="button" value="delete" onclick="edit(\''.$key.'\',\''.$b.'\')"/>';
or
echo '<a href="list_cadmin.php" onclick="edit(\''.$key.'\',\''.$b.'\')"><span class="bluetext">deactivate</span>';
the function edit() this:
function edit(a,b) { var answer = confirm("do want deactivate ?") if (answer){ alert(a) document.getelementbyid('cid').value= a; document.getelementbyid('key').value= b; document.getelementbyid('fname').method='get'; document.getelementbyid('fname').action='samepage.php'; document.getelementbyid('fname').submit(); } }
where $key , $b number , string values respectively.
so, according above both should go 'samepage.php?cid=blahblah&key=1234' on onclick. input=button working. hyperlink reloading without parameters. how hyperlink work?
you need prevent href
executing returning false onclick
:
echo '<a href="list_cadmin.php" onclick="edit(\''.$key.'\',\''.$b.'\'); return false;"><span class="bluetext">deactivate</span>';
Comments
Post a Comment