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

58
Views
How to set the value of select field to an input field

I am having a bit of problem here. I have have two fields one is a select field and the other is an input field which is readonly. What i am doing is that i am getting the value of the select and setting its value to the input field. Now here is the case where i want to save the "name" at the select field instead of the "232" but because i am setting its value to the input field whenever i change the "232" at the select to "name" the input fields value also changes to "name". How can i set the value of the select to name without changing the value of the input field which is "232"

                                        <label for="position-bottom-left"> Instruments <span class="mandatory">*</span></label>
                                        <select class="select2 form-select shadow-none" name="instrutype" id="instrutype" class="form-control demo" data-control="hue">
                                            <option selected="true" disabled="disabled">Select Intrument </option>
                                            
                                                    <option value="<?php echo "232"; ?>"> <?php echo "name"; ?></option>
                                        </select>

                                    </div>

                                    <div class="col-md-6 fieldspaceout">
                                        <label for="hue-demo">Tenure<span class="mandatory">*</span></label>
                                        <input type="text" name="tenure" id="tenure" class="form-control demo" data-control="hue" data-position="bottom left" value="<?php echo $tenure; ?>" readonly>
                                    </div>

<script type="text/javascript">
    var select = document.getElementById('instrutype');
    var input = document.getElementById('tenure');
    select.onchange = function() {
        input.value = select.value;
    }
</script>
about 4 years ago · Juan Pablo Isaza
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!