Kim
Kim

Reputation: 2166

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?

Upvotes: 0

Views: 82

Answers (1)

Paulo Fidalgo
Paulo Fidalgo

Reputation: 22311

If you are using Jquery:

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

Upvotes: 1

Related Questions