I have some basic logic here and im getting crazy how can do this. what I want is to submit my form when the hyperlink is being click. here sample code:

<form id="myForm" action="for-filtering.php">

<input type="hidden" name="fname" value="<?php echo $account_fname; ?>">
<input type="submit" id="submit" style="display:none;"/>
<a  onclick='myFunction()' href='reponse-to-customer.php?id=".$cus_id."'>$firstname_email</a>

</form>


<script>
    function myFunction()
    {
    document.getElementById("myForm").submit();
    }
</script>

I know Sir you can improve this thnx.. ^^

Why do you want it to get submitted by clicking on the link. You can make the submit button look like a link using CSS.
However if you want to do this anyways your code should look like this:

<form id="myForm" action="for-filtering.php" method="post">
 <input type="hidden" name="fname" value="<?php echo $account_fname; ?>">
 <a onclick='myFunction()' href='#'><?php echo $firstname_email; ?></a>
</form>
<script>
    function myFunction()
    {
        document.getElementById("myForm").submit();
    }
</script>

Remove the Submit button and put a method in form tag.

what I really need is to submit form while the link is still working.. its like 2 destination in just one click.. thats why i put value on href=""..

Well you can do this in myFunction:
Submit the form data using AJAX.
For AJAX you may refer to this link.
After the AJAX request is complete do: window.location.href=varLink.
Keep the href attribute to # still.
varLink contains the URL where you want to go to. It is the argument to myFunction().

Also your href

reponse-to-customer.php?id=".$cus_id."

is wrong.
Write like this: <a onclick='myFunction(<?php echo "reponse-to-customer.php?id=".$cus_id; ?>)' href="#"><?php echo $firstname_email; ?></a>

thnx sIr.. I'll try this way right away. ^^

Please mark the question solved if it is.

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.