0

I have this URL

/home/tx_besijobs_pi1 %5Bpointer%5D=1
&tx_besijobs_pi1%5Bmode%5D=1&cHash=70b49e9ffb83c0fb8010a7220bf4d833

I need to change the pointer value to '0' on next tab click.

My jquery script is given below

 <script type="text/javascript" src="js/jquery.js"></script>
 <script type="text/javascript" src="js/jquery-ui.js"></script>
 <script type="text/javascript" src="js/jquery.cookies.js"></script>
 <script type="text/javascript">

  var pointer = getUrlVars()["pointer"];

  $(function()
    {
            var cookieName ="stickyTab";

            $( "div.tabbing" ).tabs( {  

                selected: ( $.cookies.get( cookieName ) || 0 ),
                select: function( e, ui )
                    {
                            var id =  $(location).attr("href");
                            $.cookies.set( cookieName, ui.index );
                    }
                } );
    } );


   function getUrlVars()
     {
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&");

        for(var i = 0; i < hashes.length; i++)
        {
            hash = hashes[i].split("=");

            if($.inArray(hash[0], vars)>-1)
            {
                vars[hash[0]]+=","+hash[1];
            }
            else
            {
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
        }

        return vars;
    }

Since the URL is of the format tx_besijobs_pi1%5Bpointer%5D=1 .I am not getting pointer value. And I dont know how to set pointer value to 1.

1 Answer 1

1

Let say if tx_besijobs_pi1%5Bpointer%5D=1 is the string and you need to change the value from 1 to 0

var str = 'tx_besijobs_pi1%5Bpointer%5D=1';
str = str.replace("5Bpointer%5D=1", "5Bpointer%5D=0");

This is just an example, you can use this approach to update your string and then create URL out of this

Sign up to request clarification or add additional context in comments.

1 Comment

var pntr = getUrlVars()["tx_besijobs_pi1[pointer]"]; and I am getting pntr value as 1,2,... id = id.replace("[pointer]=pntr", "[pointer]=0"); This is not working.But if I put id.replace("[pointer]=2", "[pointer]=0") , Its working correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.