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

  • Home
  • SEARCH
  • 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 1027929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:18:30+00:00 2026-05-16T12:18:30+00:00

I have a sharepoint site and want to create a script for links with

  • 0

I have a sharepoint site and want to create a script for links with querystring values that are not hard coded so I can use it on several sites without having to alter it. The HTML is a mess and I can’t alter it.

I have some charts with links to a page with more details. On the page with charts I have some filters and when a user selects one of them the page reloads and the url then contains a querystring value.

With javascript I want the charts to get links depending on the querystring value so the page with more details reflects what the user selected in the filter.

The links from the charts looks something like
http://mysite.com/details.aspx?filter=train

To get this link I have a script that creates them with this

goPage[0]= baseURL + filter[queryString];
goPage[1]= baseURL + filter[queryString];

I know the possible querystring values already (max 10) so I hard coded them in an array

filter[1] = 'road';
filter[2] = 'train';
filter[4] = 'horse';

So my question is, how do I do this if I don’t know the querystring values on beforehand?

The links are dynamically added in the html document and I get all possible querystring values with:

  var businessUnitID = new Array();
  $('.table404').children().children().each(function(){
  var link = ($(this).find('a').attr('href'));
  var startIndex = link.indexOf(",'");
  var endIndex = link.indexOf("');");
  if ( startIndex >= 0 && endIndex >= 0 ) {
      var linkID = link.substring( startIndex+2, endIndex );
  businessUnitID.push(linkID);
  }
  alert(businessUnitID);
  });

Any ideas?
Thanks in advance

edit: updated the question with more information

to get the queryString I use the following code:

//Get the filter ID from the querystring

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

var queryString = gup("SelectedID");

Also, instead of having road, train etc hard coded I get it with

  var businessUnitName = new Array();
  $('.table404').children().children().each(function(){
  var linkText = ($(this).find('a').text());
  businessUnitName.push(linkText);
  //alert(businessUnitName);
  });

So instead of having:

  var filter = new Array();
  filter[1] = businessUnitName[1];
  filter[2] = businessUnitName[2];
  filter[4] = businessUnitName[3];
  filter[5] = businessUnitName[4];
  filter[7] = businessUnitName[5];
  filter[9] = businessUnitName[6];
  filter[10] = businessUnitName[7];
  filter[11] = businessUnitName[8];
  filter[14] = businessUnitName[9];
  filter[15] = businessUnitName[10];

I want to, if for example the querystring value is the third value in the businessUnitID array, set filter to businessUnitName[3];

I hope I make myself clear here, please ask if you have any further questions.

  • 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-16T12:18:31+00:00Added an answer on May 16, 2026 at 12:18 pm

    I’m not sure what you’re missing. Can’t you just do:

    for(var i=0; i < businesUnitID.length; i++) {
        goPage[i] = baseURL + businesUnitID[i];
    }
    

    However you could just add the baseURL when pushing the linkID into businessUnitID:

    If you need to have businessUnitIDs correspond to specific numbers (0,1,2), then we need more information on how to match them up.

    EDIT: based you your added info:

    I would modify the way you collect the businesUnitIDs …

    var businessUnitID = new Array();
    var i=0;
    $('.table404').children().children().each(function(){
        var link = ($(this).find('a').attr('href'));
        var startIndex = link.indexOf(",'");
        var endIndex = link.indexOf("');");
        if ( startIndex >= 0 && endIndex >= 0 ) {
            var linkID = link.substring( startIndex+2, endIndex );
            businessUnitID[linkID] = i;
            i++;
        }
    });
    

    Then you can just use filter = businesUnitName[businesUnitID[queryString]];.

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

Sidebar

Related Questions

We have a SharePoint Team Site (WSS 3.0 not MOSS), that includes Tasks list
I have a SharePoint 2007 Server and want to create a site with a
I have to call some code in a SharePoint site that runs under the
I have some code that creates a new site in SharePoint. Upon browsing to
I have 5 different infopath forms.on sharepoint site , i want to upload them
I have a requirement in sharepoint where I want to Create the top link
I have a SharePoint site extended for forms authentication. The Active Directory site is
I have a case where if a SharePoint site owner decides to break permissions
Background I have a massive db for a SharePoint site collection. It is 130GB
I have basically two separate sites, a SharePoint collaboration site, and an ASP.Net application

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.