Frage

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?

War es hilfreich?

Lösung

If you are using Jquery:

var div_id = "mydiv";
$("#"+div_id+" :input[ID^='input_id']").val('Field Value');
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top