Here is what I'm trying to do
<% form_for @color, :html => {:multipart => true, :name => "color_form"} do |f| %>
<%= f.text_field :head_color %>
and I want to use this javascript
document.color_form.color[head_color].value;
javascript obviously doesn't like this and throws an error. The problem is 开发者_StackOverflow中文版that I can't use text_field_tag. How can I get javascript to read this?
Your current code acts as if the DOM treats array_field[names] in any sort of special way, making document.color_form.color an array. Nope, it's not quite that clever.
You can still access the field by name, though, using bracket notation.
document.color_form["color[head_color]"].value
used getElementById,  duh... much easier
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论