Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Fetch or clone data from input field

I am currently having some issues with the following script:

    <input name="MYNEWVALUE" class="MYNEWVALUE" maxlength="20" type="text" id="MYNEWVALUE">
    <a onclick="addURL(this)" href="<?php echo $escaped_url?>">Click this</a>
    
    <script>
    function addURL(element)
    {
        $(element).attr('href', function() {
            return this.href + '?notes=...';
        });
    }
    </script>

As you can see I have an input field which I called MYNEWVALUE and a Button with a Javascript function. This button once clicked adds a specific parameter to my URL e.g. https://myurl.com/?notes=...

What I am currently trying to achieve is to fetch the data from the input field (as soon as the Button has been clicked) and use it or clone it directly in conjunction to this.href + '?notes=MYNEWVALUE';

So If I would enter Testing the final URL to be passed on should become https://myurl.com/?notes=Testing

Is there a way to intercept or clone this value? Some expert help would be greatly appreciated, thank you.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What you can do is change how you're handling the event handling and simplify it like so:

<a href="<?php echo $escaped_url?>" id="button">Click this</a>

<script>
    $("#button").on("click", function() {
        this.href += "?notes=" + $("#MYNEWVALUE").val();
    });
</script>

jQuery .click() documentation as follows (note you cannot use an ES6 function for this one due to the ES6 arrow function's lexical this).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!