How to gather values of multiple JS-generated input fields? - javascript

I have a form in which I have an add button. When the add button is clicked a new text box appears where user can enter some data. The user can click add button any number of times. I am using javascript to dynamically generate textboxes. I can maintain a count of the number of textboxes generated. All the values entered in these text boxes have to be stored in database using JSP. How can I store those values in the database as I do not know how many textboxes were created?

You could assign the text box count (increment an integer every time they click the Add button) to a hidden input field in the form, then retrieve the value of that field in the JSP when the form is posted.
If you give each new text box a new name, e.g. text{count}, then in your JSP just get the parameters from text0 to text{maxCount}, where maxCount is the count from the hidden field.

Related

Get All input data of radio type using javascript in html page

I have html page which contains radio type fields. I want to retrieve only specific data which belongs to the radio button fields.
I used document.querySelector('input[type="radio"]') ,but it returns only the data of first radio button field. But I want data of all radio button fields.
Please anyone help me out.!!

How to move from first row's input field to last row's input field one by one in HTML table using jquery?

Here I've a HTML table with input field like this way
<td><input></td>
and there is a lots of row in my table. What I'm trying to do is that, when I will press enter button it will move to its next input field on the next row. For clear visualization
First I'll be in the input field 1 and after pressing the enter I want to move to the input field 2 and so on. It's dynamic table and id's are not maintaining any serial. Here I forgot to mention, there will be other input field as well and pressing the enter I don't want to go to the other column input field.

How get get the entered values from input box and not the content of Value attribute

I have some input fields with pre-populated values. After editing the values of this field if the save button is pressed in my script tag I want to take the edited value in the field and send it to my controller using ajax. The problem I faced is when I am picking the value of my input field using
var name = document.getElementById('iusername').value;
I am getting the value in value attribute and not the one resulted after edit.

Text Field autofill in Laravel 5

I am trying to fill the second text box based on the input given to the first text box. For example, when the user gives the user id his other details should be filled automatically in the text fields from the database.
If you are willing to auto fix the users details by just entering the id and not refreshing the page you should better dive into AJAX. Use ajax on value enter just submit it to the any method function where you get info by id then populate it to the input field by name, id whichever you want

NaN error message in field transferring text radio button values to another field

My objective is to accumulate results of a multi-page questionnaire form into a summary page. Specifically I wish to take the selection from radio buttons and check boxes and place their values into another field on the summary page. This works fine when the radio button selections are numbers. I use the following script in the calculation pane (Custom calculation script) of the destination field of the summary page e.g.
var v1 = +getField("Hx.LBPWorst").value;
event.value=v1
The variable Hx.LBPWorst is a radio button with 11 buttons, 0-10 and the selected option is transferred to another field on the summary page without problems
My problem is that I wish to transfer text choices rather than numbers from a radio button E.g.
The radio button Hx.mech.prosit has four options “Worse”, “Better”, “NE”, “Varies”. The destination field for the selected option is a field with the format set to “None”. I have attempted to use the same structure i.e.
var v2 = +getField("Hx.mech.prosit").value;
event.value=v2
In this case the destination variable is filled with NaN i.e. Not a Number. I have read some of the questions and answers in this forum and apparently the problem is that radio buttons actually don’t store the selection as text. How can I achieve my objective and still use radio buttons (or check boxes)?
Change +getField to getField
var v2 = getField("Hx.mech.prosit").value;
The Unary plus (+) is changing the string to a number. When it can not convert it to a number, you get the NaN.

Categories