0

I need to remove the values from the url after the ? in the next page the moment i click from my first page. I tried a lot of coding but could not get to a rite path. Need help. The strings ex- Name, JobTitle and Date are dynamically generated values for ref. Below are the links associated with the code:

Required url

file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?

Resultant url:

file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?Name=Name%201&JobTitle=Title%201&Date=Entered%20Date%201

listItem.onclick = function(){  


        var elementData=listData[this.id];
        var stringParameter= "Name=" + elementData.name +"&JobTitle="+elementData.job_title+"&Date="+ elementData.entered_date;

      //window.location.href = window.location.href.replace("ListCandidateNew", "newOne") + "?" + stringParameter;
       window.location.href="file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?"
                + stringParameter;
}
androminor
  • 322
  • 1
  • 13

2 Answers2

0

This should work:

var url = file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?Name=Name%201&JobTitle=Title%201&Date=Entered%20Date%201

    var index = url.lastIndexOf("?");

    url = url.slice(0, index+1); // index+1 so that "?" is included
Anudeep Rentala
  • 150
  • 1
  • 6
0

Thanks everond for trying and attempting to answer my problem. Well, i have found the solution using window.sessionStorage as i wanted by keeping the string parameter alive to pass the values. Here is the full code:

I have two pages for passing the value from one to another: ListCandidateNew.html and newOne.html

ListCandidateNew.html

    listItem.onclick = function() 
      { 
      
    
      var elementData=listData[this.id];
      var stringParameter= "Name=" + elementData.name +"&JobTitle="+elementData.job_title+"&Date="+ elementData.entered_date;
    
   
        window.sessionStorage['Name'] = elementData.name;
        window.sessionStorage['JobTitle'] = elementData.job_title;
     window.sessionStorage['Date'] = elementData.entered_date;

**newOne.html**

function LoadCandidateDetail()
 {  
    document.getElementById('Name').innerHTML = window.sessionStorage['Name'];
    document.getElementById('JobTitle').innerHTML = window.sessionStorage["JobTitle"];
       document.getElementById('Date').innerHTML = window.sessionStorage["Date"];
 }  
androminor
  • 322
  • 1
  • 13