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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:38:15+00:00 2026-06-11T15:38:15+00:00

This is code I took over from a colleague who left: <input type=text class=value

  • 0

This is code I took over from a colleague who left:

<input type="text" class="value" placeholder="0"></span><br>
<a href="/model/act/id/'.$model->id.'" class="act act-a" url="/model/act/id/'.$model->id.'">Act Now</a>

<script>
    $('.act-a').click(function(){
        if(parseInt($('.value').val())>0){
            //window.location.href = window.location.origin + $(this).attr('url') + '?r=' + parseInt($('.value').val());
            window.location.replace("www.google.com");
            return true;
        }
        return false;
    });
</script>

When I click on the link, I never get redirected to http://www.google.com. Originally what I want is to execute the commented code, but setting http://www.google.com to debug, I think to realize that my redirection is being ignored, and instead the original href from the is used!

How can I set window.location.href when a link has been clicked, adding a GET parameter?

  • 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-11T15:38:16+00:00Added an answer on June 11, 2026 at 3:38 pm

    return true; tells the browser to do the link’s default action. So, the browser is following the link instead of running window.location.

    Remove both the return statements, and instead add e.preventDefault();

    $('.act-a').click(function(e){
        e.preventDefault();
        if(parseInt($('.value').val(), 10) > 0){
            window.location.href = window.location.origin + $(this).attr('url') + '?r=' + parseInt($('.value').val(), 10);
        }
    });
    

    P.S. You should add ,10 to parseInt to make sure the number is parsed as base 10.

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

Sidebar

Related Questions

So, I took some code from this Microsoft provided Example which allows me to
Ok i have this piece of code from which i took from W3schools :-
I took the code from this example. http://msdn.microsoft.com/en-us/library/2tw134k3.aspx What I am wondering (and I've
I took this code from Facebook's documentation to get me started in learning how
I took some sample code to create a drop down menu from this website:
When looking through some code I took over, I came across this line: my
I need measure how time took a scriptblock (remote execution). This is my code:
This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this
Just recently took over a project from my developer. I'm a noob to coding,
So I took over an existing iOS app from a client, that is currently

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.