Question

I'm trying to get the first "Order Name" field in a form to automatically fill in other "Order Name" fields on other pages of the form using Blade Templating inside Laravel. The form will be split up to different people depending on the order so the contact info needs to be on every page.

I wanted to give the first "Order Name" input field a class of "general_order_name" and the other name fields throughout the form the class "order_name". The idea being that the text in "general_order_name" would be copied to a variable and then placed inside all the inputs with the class of "order_name" but for some reason it is not working.

If anyone can point out where I went wrong or explain how to fix this it would be very much appreciated! Thanks!

HTML:

{{  Form::label('order_name', 'Order Name:')    }}
{{  Form::text('order_name', null,
    array('class' => 'general_order_name')) }}

{{  Form::label('page_name', 'Order Name:') }}
{{  Form::text('page_name', null,
    array('class' => 'order_name'))      }} 

JS:

    $(document).on("change", ".general_order_name", function(){
    var order_name = $(this).value();
    $('.order_name').value(order_name);
}); 
Was it helpful?

Solution

jQuery uses val() not value

$(document).on("change", ".general_order_name", function(){
    var order_name = $(this).val();
    $('.order_name').val(order_name);
}); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top