ruby-on-railsrjs

set value of field using rjs


I need to set the value of a field in my form using rjs.

That field in question appears twice in my form and I want to set the value of the field found inside a particular div only.

The code below does not seem to work.

page[:mydiv_id][:book_bk_title].value = "myvalue"

My question is how do i set the value of a field by also specifying the div containing it. using rjs?


Solution

  • If you are using Jquery:

    var div_id = "mydiv";
    $("#"+div_id+" :input[ID^='input_id']").val('Field Value');