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

100
Views
how to change input box value in html when selectbox is selected without changing the select box value

i am trying to integrate payu payment gateway in my website so when a user selects the product info in my form, the amount should change accordingly, I have done the following:

function myFunction(e) {
    document.getElementById("myText").value = e.target.value
}
<select name="productinfo" onchange="myFunction(event)" class="form-control">
  <option value="<?php echo (empty($posted['productinfo'])) ? '' : $posted['productinfo']; ?>" disabled selected>Choose Database Type</option>
  <option value="26,999">X 1.5</option>
  <option value="28,999">X 2.5</option>
  <option value="32,999">X 3.5</option>
  <option value="35,999">X 4.5</option>
</select>

<input type="text" name="amount" id="myText" class="form-control"   value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount']; ?>" readonly>

here the amount is being changed according to product select and am able to pass it to pay, what I want is the product info also to be passed like value="X2" in the form, is there any way to do it,please help, thanks in advance

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

0

Here try this:

function myFunction(e) {
    document.getElementById("myText").value = e.options[e.selectedIndex].getAttribute('data-price');
}
<select name="productinfo" onchange="myFunction(this)" class="form-control">
  <option value="<?php echo (empty($posted['productinfo'])) ? '' : $posted['productinfo']; ?>" disabled selected>Choose Database Type</option>
  <option value="X 1.5" data-price="26,999">X 1.5</option>
  <option value="X 2.5" data-price="28,999">X 2.5</option>
  <option value="X 3.5" data-price="32,999">X 3.5</option>
  <option value="X 4.5" data-price="35,999">X 4.5</option>
</select>

<input type="text" name="amount" id="myText" class="form-control"   value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount']; ?>" readonly>

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!