Text Field autofill in Laravel 5 - javascript

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

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.!!

Command external field value to be sent with form

I have two forms on one page.
The first form is used to make a calculation (fieldvalue1 + fieldvalue2 = calculatedfield)
The second form is simply just to capture information (Name, Email, etc.)
The first form has no submit button, but the second form has a submit button. Currently, when the user fills in all the info and clicks submit, then only the second form's fields get sent to my admin email.
Is there a way to send calculatedfield along with the form fields sent to my email when clicking the submit button on the second form?
I would like to add a code snippet to command the calculatedfield to also be sent along with the fields of the second form. Not sure which code to use...
I would greatly appreciate any assistance.
Add a new hidden field (lets call it hiddenCalculatedField) to your second form.
In the first form, add a onChange hook to the calculatedfield, and copy the value to the hidden field. This will get submitted when the second form is submitted.
In this example, it assumes
$(document).ready(function() {
$("input[name='calculatedfield']").change(function() {
$("input[name='hiddenCalculatedField']").val($(this).val())
})
}

How to validate two user's details on a single page, using jquery's validate()?

There is a page where first user's details are entered.
Say,
First user input fields are- Name[mandatory], Address[mandatory], Contact No.[mandatory] and Photo. [optional]
There is a + button if it wants to enter another details.
If + is clicked, the same details with different input names gets cloned.
Second user details - sName[mandatory], sAddress[mandatory], sContact No.[mandatory] and sPhoto[optional].
Now, using jquery's .validate how to validate second user?
Say, if the first user entered details, clicked + , entered sContact No. , it should display error as all s fields are missing.
Similarly, if I validate sName by using 'depends' , what if sName is empty? All other fields will be entered without validation in that case.
Please suggest how to put validation in such case?

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.

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

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.

Categories