vendredi 17 avril 2015

Want to be able to copy the value of a text_filed_tag to another text_field_tag

Questions is I would like to copy the value of this text field tag to another text_field tag I tried this, but its not working..any help would be greatly appreciated thank you!!


This is my view



-if @dimension.style =~ /visual/i
.control-group.radio_buttons.custom_radio
.controls
= content_tag :label, :name => "sample_dimensions_#{sample.id}_value_1", :class => 'radio custom_radio' do
= radio_button_tag "dimension[samples][#{sample.id}][value1]", 1, sample.value_for_dim(@dimension, index+1) == 1, :class => 'radio_button'
Pass
= content_tag :label, :name => "sample_dimensions_#{sample.id}_value_0", :class => 'radio custom_radio' do
= radio_button_tag "dimension[samples][#{sample.id}][value1]", 0, sample.value_for_dim(@dimension, index+1) == 0
Fail
-else

#I tried giving it an id but still isnt working
=text_field_tag "dimension[samples][#{sample.id}][value1]", sample.value_for_dim(@dimension, index+1), :id => 'reading1' , :step => "0.000001"


-when 1
-if @dimension.style =~ /visual/i
.control-group.radio_buttons.custom_radio
.controls
= content_tag :label, :name => "sample_dimensions_#{sample.id}_value_1", :class => 'radio custom_radio' do
= radio_button_tag "dimension[samples][#{sample.id}][value2]", 1, sample.value_for_dim(@dimension, index+1) == 1, :class => 'radio_button'
Pass
= content_tag :label, :name => "sample_dimensions_#{sample.id}_value_0", :class => 'radio custom_radio' do
= radio_button_tag "dimension[samples][#{sample.id}][value2]", 0, sample.value_for_dim(@dimension, index+1) == 0
Fail
-else

#I tried giving it an id but still isnt working
=text_field_tag "dimension[samples][#{sample.id}][value2]", sample.value_for_dim(@dimension, index+1), :id => 'reading2', :step => "0.000001"


Here is my javascript with the function to copy the value of reading1 to reading2



$("#reading1").change(function() {
var text = $("#reading1").val();
$("#reading2").val(text);
});

Aucun commentaire:

Enregistrer un commentaire