Tips for saving the chosen dropdown value into a div

I would like to save all the input values from a form into separate divs as they are entered.

For text input boxes, I have successfully implemented it using the following code:

<input type="text" class="form-control" onkeyUp="document.getElementById('ref7').innerHTML = this.value" name="bank_name" id="bank_name">

But I am now wondering how I can achieve the same functionality for dropdown box selected values.

Here is my select box:

<select class="select form-control" id="payment" required name="payment" onkeyUp="document.getElementById('ref14').innerHTML = this.value">
    <option value="" disabled="disabled" selected="selected">Please select</option>
    <option value="As per signed contract accpetable">
        As per signed contract acceptable
    </option>
    <option value="As per contract not accpetable">
        As per contract not acceptable (please specifiy the fee below)
    </option>
</select>

<div id="ref14"></div>

Answer №1

When using the select element, it is recommended to use the onchange event instead of the onkeyUp event.

Learn more

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How does the rest operator in Javascript work when dealing with a different array input?

The following code snippet shows a function that uses Insertion Sort to sort an array of heights. The values being passed in are 4, 1, 9, 14, 6, and 8, and the sorted order should be 1, 4, 6, 8, 9, 14. var heightChecker = function(heights) { var sorte ...

How to dynamically update data in Angular without the need for a page refresh or loading?

Looking to enhance a wishlist feature by enabling users to delete items from the list without the need for a page refresh. Here's my approach: wish.controller('wishCtrl',['$scope','$http','$cookies','$wind ...

Is there a problem with Framer Motion exit and AnimatePresence in Next.js?

Why isn't my exit prop or AnimatePresence working as expected? This is my custom variant: const imgVariant = { initial: { opacity: 0, y: -100, }, animate: { opacity: 1, y: 0, transition: { type: " ...

Does Express restrict multiple pending requests from a single IP address?

I am currently developing a chat application that utilizes long polling with express. While I am aware that websockets are considered better for this purpose, I wanted to challenge myself by specifically implementing long polling. When a client is waiting ...

retrieve the parent bracket string excluding any nested brackets

Let's consider the following expression within a string: (3 + (7 - 5)) - (20 / 10) The task is to extract only the parent expressions: ['3 + (7 - 5)', '20 / 10'] An attempt was made using the indexes of opening and closing parent ...

The message sent back by Django Rest Framework is: "a legitimate integer must be provided"

I have integrated a react form within my Django application, supported by the rest framework in the backend. When I submit the form without entering any value in the integer field, I encounter the following error message from the rest API: "a valid integer ...

Obtaining the data from a div element with a class containing an empty tag using Python's

I am having trouble extracting the value '5' from the following : <div class="DrugPriceBox__price___dj2lv">₹<!-- -->5</div> Unfortunately, the python-beautifulsoup code I used is not returning anything: drugprice=so ...

Is there an XML File Wrapper to Generate PDF Output?

Greetings Forum Members, I have been given the responsibility of creating a PDF file from multiple XML files. Has anyone come across an XML wrapper file before? This type of file would essentially contain a list of all the source XML file names in a spec ...

Handlebars does not have the ability to extract information from JSON files

I am attempting to extract the title from this JSON data: { "feed" { "title" { $t: "animals" text: "" } } } (Please note that the JSON structure provided is for example purposes only. The complete JSON file ...

Locate and dismiss a toast message (Toastr)

I have a webpage where I can add multiple popup notifications called toasts dynamically using the toastr plugin found at https://github.com/CodeSeven/toastr. Each toast has an Ok link that, when clicked, should only close that specific toast and not all v ...

Pair a specific portion of text with another string

I'm having trouble finding a substring within a string. The substring and the string are as follows: var str="My name is foo.I have bag(s)" var substr="I have bag(s)" When I use str.match(substr), it returns null, probably because the match() funct ...

Click to toggle information using Jquery

I am attempting to create a button that, when clicked, will toggle between displaying temperature in Fahrenheit and Celsius. While I have been able to make it work initially, the toggle only occurs once and then stops. I have experimented with separate if ...

How can I utilize Material-UI's Grid component to make a single cell occupy the entire remaining horizontal space?

I am currently utilizing the Grid component from material-ui in my React 16.13.0 application. My objective is to create a row with three items. The first two items are supposed to occupy only the required space without specifying pixel values. I want the t ...

Having trouble retrieving the default selected value using the index in Angular Material's mat-button-toggle functionality

I'm encountering an issue with setting the default value for a toggle button group. The code is simple and the toggle buttons are correctly fetching values from the index, but I can't seem to get one of them to be default selected. I tried settin ...

Tips on Extracting Data from a JSON Object with an Embedded Array

Check out this example of a Json Object: {"UserName":Mike,"IsActive":0,"ChbxIsActive":false,"MyAccountsAvailable":[{"Id":"157A","MyAccount":"CHRIS MCEL","MyCheckBox":false,"Tags":null},{"Id":"157B","MyAccount":"DAN BONE","MyCheckBox":false,"Tags":null} He ...

display a list of items in the dashboard using Angular 2 md-sidenav when clicked

I've successfully implemented a sidebar navigation menu in Angular 2, resembling the image shown in the link below: https://i.sstatic.net/KFvJQ.jpg UPDATE: However, I'm facing an issue where clicking on a category link within the sidebar doesn ...

I can't figure out why the item.newStock number is always one less when I click the button with the Up function in React

Currently in the process of developing a small e-commerce platform with a focus on enhancing the shopping cart feature. The objective is to have the array update and display on the screen via item.newStock every time the Up button is clicked. However, upon ...

Guide to updating the options of a UI select dynamically using AngularJS

I am working on implementing a dynamic feature for my UI Selects. Specifically, I have multiple UI Selects and I want to load choices into the second one based on the selection made in the first one. Despite my extensive search, I have not been able to fin ...

Dealing with complications in the Rails asset pipeline management

I am working on a webpage that requires real-time data to be displayed. Therefore, it necessitates continuous ajax communication post page load. similar to this, jQuery -> setInterval -> $.ajax url: "some url" success: (data, te ...

What is causing the initial activation of the <button> within a form?

Within my <form>, I have included 2 submit buttons. The first button looks like this: <button class="regular" id="geocodesubmit" style="height:40px;">Set Location</button> The second button looks like this: <button type="submit" ...