0

Using RJS:

page[:greeting].replace_html 'Hello World!' replaces the text in the 'greeting' field with 'Hello World'.

I have a drop down list and would like to select an option with a specific id using rjs.

My question how do I select an option from a drop down list with id "sub_book" using rjs.

Thanks for your help

2 Answers 2

0

Try

<select id="sub_book">
  <option value="1">First</option>
  <option value="2">Second</option>
  <option value="3">Third</option>
  <option value="4">Fourth</option>
</select>

<script type="text/javascript"> 
$(document).ready(function() {
    $("#sub_book").val(3);
});
</script>
0

Here is the solution I used:

page["sub_book"].selectedIndex = 5 //in this case am selecting the option with id 5

Hope it might be of help to somebody else

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.