Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7081831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:58:14+00:00 2026-05-28T06:58:14+00:00

<?php $sort=$_REQUEST[‘sortby’]; echo $sort ; ?> <html> <head> </head> <body> <form method=get id=thisForm >

  • 0
<?php
$sort=$_REQUEST['sortby']; 
 echo" $sort ";  
?>  
<html>
<head>  
</head>
    <body>  
<form method="get" id="thisForm" >  
          <table border=1>  
        <tr>  
            <td>  
                <a href="" name="say" onclick="javascript: sorting(0)">Day </a>
            </td>
            <td>
                <a href="" name="server" onclick="javascript: sorting(1)">Server </a>  
            </td>  
            <td>  
                <a href="" name="service" onclick="javascript: sorting(2)">Service </a>  
            </td>  
            <td>  
                <a href="" name="count" onclick="javascript: sorting(3)">Count </a>  
            </td>  
        </tr>  
    </table>    
        <input type="hidden" name="sortby"  id="sortby"/>  
    </form>  
    </body>  

<script type="text/javascript" >  

var sortArray=new Array("say","server","service","count");  
function sorting( cnt)  
{  
    alert(sortArray[cnt]);  
    document.getElementById("sortby").value=sortArray[cnt];  
}  

Based on the Header clicked i am trying to build a sort query but after it is submitted on clicking the “a href” link i am unable to get the hidden field posted data ?

I have changed “a href” to submit buttons then how do you stop the page being submitted if we click the same “sort by” link.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:58:14+00:00Added an answer on May 28, 2026 at 6:58 am

    Here is what you’re missing:

    • A link does not submit the form with input data, it just changes the url.
    • Submit the form.
    • Override the default <a> behavior (for example, using return false).

    An updated version of sorting:

    var sortArray=new Array("say","server","service","count");  
    function sorting(cnt)  
    {  
        document.getElementById("sortby").value = sortArray[cnt];  
        document.getElementById("thisForm").submit();
        return false;
    }  
    

    You can call it using:

    <a href="" name="say" onclick="return sorting(0);">Day </a>
    

    Working example: http://jsbin.com/ukoton/3

    Another option is to use the popular library jQuery, which can greatly simplify your code:

    $(function(){
      $('#thisForm a').click(function(ev){
        var sortValue = this.name;
        // an alternative to this.name is to use a data-sortBy='day' attribute, 
        // and then $(this).data('sortBy')
        $('#sortby').val(sortValue);
        $('#thisForm').submit();
        ev.preventDefault();
      });
    });
    

    Working example: http://jsbin.com/ukoton/4

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the best way in PHP to sort an array of arrays based on
I have some PHP code which allows me to sort a column into ascending
What is an elegant way to sort objects in PHP? I would love to
Is there a simple way to sort an iterator in PHP (without just pulling
I'm kind of stuck with my heap sort here in php: <?php function heapSort($a,
I have seen hooks in Kohana PHP framework, and they work as some sort
This is a topic that, as a beginner to PHP and programming, sort of
<mx:HTTPService id=addWeb resultFormat=object result=Added(event) fault=faultWeb(event) showBusyCursor=true method=GET url=http://localhost/search/populate.php useProxy=false> <mx:request xmlns=> <urlWeb>{urlW.text}</urlWeb> </mx:request> </mx:HTTPService>
I have a data table populated from a MySQL database via PHP. The first
I'm trying to make a sort of PHP bot. The idea is to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.