Hi All,

I have a javascript adding an input text. I couldn't get it to work
with Haml.
When I click on "Add" button, it should add a new input text.

Can you help me what I am doing wrong?

Thanks,
Luan

================================
edit.haml
================================
:javascript
  function show_alert()
  {
  alert("I am an alert box!");
  }

  function addRow()
  {
  alert("in addRownew()");
  //Create an input type dynamically.
  var element = document.createElement("input");
  //Assign different attributes to the element.
  element.setAttribute("type", "text");
  element.setAttribute("value", "text");
  element.setAttribute("name", "text");
  var foo = document.getElementById("fooBar");
  //Append the element in page (in span).
  foo.appendChild(element);
  }

%h1 Edit
%form{:method => "post", :action => "/contacts/"}
  %input{:type => "hidden", :name => "_method", :value => "put"}
  %input{:type => "hidden", :name => "id", :id => "id", :value
=>"#{@form.id}" }
  %label First Name:
  %input{:type => "text", :name => "first_name", :id =>
"first_name", :value =>"#{@form.first_name}" }
  %br
  %label Last Name:
  %input{:type => "text", :name => "last_name", :id =>
"last_name", :value => "#{@form.last_name}"}
  %br

  %input{:type => "submit", :value => "Save Changes"}

  %input{:onclick => "show_alert()", :type => "button", :value =>
"Show alert box"}
  %input{:onclick => "addRow()", :type => "button", :value => "Add"}

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to