开发者

show text field on select other from drop down :ROR

开发者 https://www.devze.com 2023-03-08 12:22 出处:网络
How I should do this using javascript? I looked other places but e开发者_JAVA技巧very example uses Jquery.

How I should do this using javascript? I looked other places but e开发者_JAVA技巧very example uses Jquery.

Only on select other textbox should visible.


Assuming that you are on an older version of rails which has prototype as the js library.

in the onchange event of the select list add the javascript function to show the div containing the text box (let's say you show the text box for value 5 of the select list):

<select id="select_item" name="select_item" onchange="display_date_range(this);">
... where 5 is the value of the option that needs to show text box
</select>

  function display_date_range(list) {
    if(list.options[list.selectedIndex].value == 5) {
      $("text_div").show();
    }
    else {
      $("text_div").hide();
    }
  }

<div id="text_div"><input type="text" value="Hooraaahhh..." /></div>
0

精彩评论

暂无评论...
验证码 换一张
取 消