I would like to pass values in anchoring.
Keeping it visible I can use <a href=xyz.php?ID=123&action=delete>

In above I would like action=delete to be hidden. What to do?

I cannot use input type=hidden as I'm not submitting the form.instead requires onclick by clicking on reference page in anchoring and passing the hidden values in URL.

Can't I use <a href="xyz.php?ID=123&<?php <input type=hidden name='action' value='delete'>">

Recommended Answers

All 5 Replies

Use ajax to call the xyz.php

following is the sample,
you can have 2 forms and onclick you can use javascript fuction to post your values to xyz.php.

<script lang='javascript'>
function delete_record(id,act)
{
   
   document.getElementById('ID').value=id;
   document.getElementById('action').value=act;
   document.actionform.submit();
}
<script>
<form name='actionform' id='actionform' action='xyz.php' method='post'>
<input type='hidden' name='ID' id='ID'>
<input type='hidden' name='action' id='action'>
</form>
</form>

<form name='mainform' id=mainform action='somepage.php'  method='post'>
rec 1<a onclick="javascript:delete_record(123,'delete');">Delete</a><br>
rec 2<a onclick="javascript:delete_record(124,'delete');">Delete</a><br>
rec 3<a onclick="javascript:delete_record(125,'delete');">Delete</a><br>
</form>
commented: Useful post +7

Then I used the same method fr action=edit.

function editRecord()
 {
     document.getElementById("action");
     document.actionEdit.submit();
 }

<form name="actionEdit" id="actionEdit" action="./abc.php?page=xyz" method="post">

   <input type="hidden" name="action" id="action" value="edit" />

  </form> 

It doent submit the** action=edit**. Where am I wrong?

please post the screen shots it will be help us....

You're using POST method, not GET. How you receive that "action" $_GET will not get any value from the form. It should be $_POST;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.