ruby on rails - How to display previous value on Min Miles text field -


enter image description here

i want display previous value on min miles , should not editable. want

  1. default value of min miles 0.
  2. when click on add more range in new form - min value should max value of previous form.

i using semantic form for. please me. how can this...

regarding second question, , assuming new form appears through javascript, without page reloading, can grab field value javascript , use default value new field. "add new range"

something function getvalue(){
var inputtypes_max = [],inputtypes_min = [],inputtypes_amount = [];

$('input[id$="max_miles"]').each(function(){   inputtypes_max.push($(this).prop('value')); });  $('input[id$="amount"]').each(function(){   inputtypes_amount.push($(this).prop('value')); });  var max_value_of_last_partition = inputtypes_max[inputtypes_max.length - 2]  var amount_of_last_partition = inputtypes_amount[inputtypes_amount.length - 2] if (max_value_of_last_partition == "" || amount_of_last_partition == "" ){    alert("please fill above details first"); }else{   $("#add_more_range_link").click();   $('input[id$="min_miles"]').each(function(){     inputtypes_min.push($(this).prop('id'));   });   var min_id_of_last_partition=inputtypes_min[inputtypes_min.length - 2]   $("#"+min_id_of_last_partition).attr("disabled", true);    $("#"+min_id_of_last_partition).val(parseint(max_value_of_last_partition) + 1)  } 

}

i have used jquery's end selector in loop value of max , amount field per form , ids of min_miles field , setting value of min_miles per max_miles

it worked me hope works you.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -