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 7521127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:11:00+00:00 2026-05-30T02:11:00+00:00

I am trying to get a sql query to run on drop down menu

  • 0

I am trying to get a sql query to run on drop down menu selection. Here is what I have so far:

<script>
$('#templateid').change(function(DoUpdateOnSelect) {
$.post('page.edit.php?page_id=(-->Need help in getting this id from the page url<--)&template='+this.options[this.selectedIndex].value);
});
</script>

And the drop down:

<select name="templateid" id="templateid" onchange="DoUpdateOnSelect">
    <option >Contact</option>
    <option >News</option>
    <option >Home</option>
</select>

page.edit.php has conditions on it which will run the sql query if it detects the page id and the template in the URL. The template parameter value is grabbed with the jquery (please let me know if that part is set up wrong in the jquery) from the select drop down menu. What I can’t figure out is how to grab the page_id parameter from the current url of the page, and insert that into the function so that the page.edit.php?page_id=1&template=Home will be the correctly outputted URL.

Please let me know if you need further information. Thanks in advance.

EDIT: BASED ON ANSWER BELOW:

function querystring(name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
  return "";
else
  return results[1];
}
$('#templateid').change(function() {
   var page_id = querystring('page_id');
   var url = '?VIEW=EDITPAGE&linklabel='+page_id+'&template='+(this.options[this.selectedIndex].value);
$.post(url);
});

NO CHANGE IS HAPPENING WHEN I MAKE A SELECTION IN THE DROP DOWN MENU

  • 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-30T02:11:01+00:00Added an answer on May 30, 2026 at 2:11 am

    for getting the page_id from the url you should use a function like

    function querystring( name )
    {
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href );
      if( results == null )
        return "";
      else
        return results[1];
    }
    

    then you could retrieve it with

    var page_id = querystring('page_id');
    

    so, your onchange handler would look something like:

    $('#templateid').change(function() {
       page_id = querystring('page_id');
       var url = 'page.edit.php?page_id='+page_id+'&template='+this.options[this.selectedIndex].value);
       $.post(url, function(response){
          //your logic here
       });
    });
    

    oh, and please remove the onchange attribute from the select markup:

    <select name="templateid" id="templateid">
        <option >Contact</option>
        <option >News</option>
        <option >Home</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get an insert/return primary key SQL query to run. The
I have the following SQL query that I am trying to run inside Microsoft
I am trying to get my linq query to replicate my t-sql but I
I have been trying for a long time to get SQL Server Express on
I am trying to run a Linq-to-SQL query, but when the query is evaluated,
I'm trying to run a query from ADO.NET using SQL Server 2008R2. I'm using
I am trying to get two dates from a SQL query, and compare them.
I'm trying to run a query in SQL Server 2008 against a table where
I'm trying to run a webmethod via a jQuery which will query an SQL
I have the following SQL query , it seems to run ok , but

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.