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

196
Views
Automatic form fill value from previous input with javascript/jquery

I need for a duplicated form to be autofilled since it's being displayed on two different pages, so the user doesn't need to fill it twice. The form in question is a delivery fee one, where the user fills in their zip-code and the fee is calculated.

The second form suggests the autofill from the previous one, I'd just like for it to be automatically filled and selected.

Data from the first form: first form picture

<input type="tel" name="PostalCode" id="PostalCode" maxlength="9" size="9" data-name="CEP" placeholder="Calcule seu frete" class="valid" aria-invalid="false">

Which should already be populated and selected on the following form second form picture

<input data-param-id="PostalCode" id="PostalCode" data-mask-postalcode="" maxlength="9" type="text" value="11040-221">

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

0

ID need to unique, take care of it.

You can use val() to get value from the last input and use val() again to put it in first.

You can use focus() to select the input.

Tell me if i dont understand well your problem.

/*$('#PostalCode[data-name=CEP]').bind("change keyup input",function() { 
    let currentValCEP = $(this).val();
    $('#PostalCodeNext[data-param-id=PostalCode]').val(currentValCEP);
});*/

/*$('#first[data-name=CEP]').bind("click button",function() { 
    let currentValCEP = $('#first[data-name=CEP]').prevAll('#PostalCode').val();
    $('#PostalCodeNext[data-param-id=PostalCode]').val(currentValCEP);
});*/


let currentValMask = $('#PostalCodeNext').val();
$('#PostalCode').val(currentValMask).focus();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="tel" name="PostalCode" id="PostalCode" maxlength="9" size="9" data-name="CEP" placeholder="Calcule seu frete" class="valid" aria-invalid="false">
<br><br>
<input data-param-id="PostalCode" id="PostalCodeNext" data-mask-postalcode="" maxlength="9" type="text" value="11040-221">

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!