Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hi Experts,

C#
function BtnSelect_Click_Complete(values) {
            var ofiledname;
            //alert('aaa');
            ofieldname = gup('fieldname');
            if (ofieldname != null) {
                //alert(ofieldname + " : " + values[0] + " : " + values[1]);
                window.opener.SetLookup(opener.document, ofieldname, values[0], values[1]);
                window.opener.PopulateParticipant(values[0], ofieldname);
            }
            self.close();
        }


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


tmpURL is getting : http://localhost:59037/ParticipantList
results is getting : ""

But result should get : either 'ComplainantID' or 'RespondentID'

I am totally stuck at this point. Please help me.
Posted
Comments
virusstorm 6-Jul-15 17:12pm    
You need to explain to us what your code is doing and what issue or error you are running into. We need more details to better understand what your issue is.
[no name] 6-Jul-15 17:50pm    
Thank you for your quick reply. You are so kind. results variable gets null but it should have value either ComplainantID or RespondentID.
virusstorm 6-Jul-15 17:58pm    
Looking at your code, I'm not sure how the variable "results" will ever have the the values you are looking for. Try going to http://regexlib.com and input your RegEx and your tmpURL there. You will find that your RegEx isn't working or you are not supplying enough information in your tmpURL.

1 solution

You apply the regex on URL string.Is it what you want ?

My guess is that you want you apply it to the contain of the page at url.
in this case you have to download the page first, and apply regex to the page, not the URL.

For the load part of the problem, it looks like the solution depend on which library you use (JQuery) and on the format of data (html, xml, text).

In any case, at least while making things, I recommend to split your program in a way that ease testing of parts.
Make sure each part works separately, when all works, you can put together confidently.

w3schools.com is a good place to go for self teaching.
 
Share this answer
 
v3
Comments
[no name] 7-Jul-15 10:01am    
Hi ppolymorphe,

Thank you so much for your reply. How can I download the page and apply regex to the page. Please help me. I guess you are close to my solution. Your kindness will be great help for me.

Please help me.
Patrice T 7-Jul-15 14:02pm    
I am not so skilled in JS, but your code was simple enough to spot the problem.
[no name] 7-Jul-15 15:11pm    
Thank you so much.
Patrice T 7-Jul-15 16:13pm    
You're welcome.
If you feel my response answered your question, you can validate the answer and close the question.
If you don't find a solution to the page load in a variable, you may open another question on this specific problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900