How do I append a string to search query only once ?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jarid3421
Forum Newbie
Posts: 7
Joined: Wed Jul 30, 2014 4:06 pm

How do I append a string to search query only once ?

Post by jarid3421 »

The code is JScript .NET, which is basically a .NET version of Javascript.Regardless of language, Anyone with appending type of skill can answer my question

The problem is, when I keep issuing the request it keeps appending over and over again, http://i.imgur.com/nKCvgKn.png

Code: Select all

if (oSession.uriContains("q=")) 
{
    var str = oSession.fullUrl;
    var sAppend = "+test1+test2+test3";
    if (!oSession.uriContains(sAppend))
    {
        oSession.fullUrl = str.replace( "q=","q="+sAppend);
    }
}
Can you please give me an example? I'm still new to programming.

Thank you
phpdeveloper1
Forum Newbie
Posts: 19
Joined: Tue Aug 12, 2014 6:13 am
Location: Chennai, India

Re: How do I append a string to search query only once ?

Post by phpdeveloper1 »

jarid3421 wrote:..............................
The problem is, when I keep issuing the request it keeps appending over and over again, http://i.imgur.com/nKCvgKn.png
Have you tried

Code: Select all

    oSession.fullUrl = str.replace( "/q\=.*?/","q="+sAppend);
Chris, Php Developer and Programmer,
https://www.phpfreelanceprogrammer.com/
Post Reply