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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:08:11+00:00 2026-06-02T09:08:11+00:00

I am very new to this I have this link: <a onclick = sendRequest(‘GET’,’room_chart.jsp’)

  • 0

I am very new to this

I have this link:

<a onclick = sendRequest('GET','room_chart.jsp') href=#>Show Chart</a>

but I need to generate dynamic address inside that link.

I created javascript:

    <script language="javascript">
        var selectedOption;
        var ROOM;
        var BUILDING;

        function GetLink(){
            selectedOption = document.getElementById("roomandbuildingid").options[e.selectedIndex].text;  //getting selected option
            ROOM = selectedOption.split("|")[0].trim().split(":")[1].trim(); //parsing text
            BUILDING = selectedOption.split("|")[1].trim().split(":")[1].trim(); //parsing text
            return "'room_chart.jsp?room="+ROOM+"&building="+ BUILDING+"'"; //returning url
        }
    </script>

but when I paste the function into it- it does not work!

<a onclick = sendRequest('GET',GetLink()) href=#>Show Chart</a>

Now, after debug, I found out that actually it creates the proper srting, but somehow my function is not willing to accept it as URL! It is quite a paradox- it creates correct string- if I hardcode it into the code- it works! But dynamic links from variables – don’t work!

please help!

see below:
my js file:

function createRequestObject(){
    var req;
    if(window.XMLHttpRequest){
        //For Firefox, Safari, Opera
        req = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){
        //For IE 5+
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        //Error for an old browser
        alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
    }
    return req;
}

//Make the XMLHttpRequest Object
var http = createRequestObject();

function sendRequest(method, url){
    if(method == "get" || method == "GET"){
        http.open(method,url);
        http.onreadystatechange = handleResponse;
        http.send(null);
       // alert( document.URL );
       // document.write (GetLink());
    }
}
function handleResponse(){
    if(http.readyState == 4 && http.status == 200){
        var response = http.responseText;
        if(response){  
            document.getElementById("ajax_res").innerHTML = response;
        }
    }      
}
  • 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-06-02T09:08:12+00:00Added an answer on June 2, 2026 at 9:08 am

    OK, the function was returning everything correctly, the parsing was not done right. I fixed it. JavaScript is hard for me to debug.

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

Sidebar

Related Questions

Im very new to all coding including jquery. I though this would have been
This is very weird. I have the following code: Assert.AreEqual(new DateTime(2000, 1, 1), DateTime.ParseExact(2000,
I am very new to css so this maybe a simple answer. I have
I'm very new to programming and have followed this screencast at emersonlackey.com on adding
I'm very new at this, but I need to create new tables from existing
I'm very new to this, so any help is appreciated. I'll use the Dinners/RSVPs
I am all very new to this and am trying to use extended hex
I am very new to this kernel thing. What I want to do is
I am very new at all this c# Windows Phone programming, so this is
Hi i am very new to java and this is my first piece of

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.