please help forms...

Hi friends,

please help me....

my template is:
view.rhtml
<form action="/a/create">
<div id="first">
<div><input type="text" name="empfirstname"/></div>
<div><input type="text" name="emplastname"/></div>
</div>
<div id="second">
<div><input type="text" name="empfirstname"/></div>
<div><input type="text" name="emplastname"/></div>
</div>
</form>

My controller is....

def create
  @firstname=params[:empfirstname]
  @lastname=params[:emplastname]
  @contacts = Contactbook.get :firstname => @firstname, :lastname =>
@lastname
  end

Enter <div id="first"> this div only working

But.... Second <div id="first"> not working

Get only first div datas only....
please help me...

Thanks.

That's what rails does if two inputs have the same name: it only uses
the first one (unless the name ends with [], in which case you'll get
an array with all the values).

Fred

function switchEmailLogin(vendor) {
if(vendor=="first") {
document.getElementById('second').style.display = "none";
document.getElementById('first').style.display = "";
}
else if(vendor=="second") {
document.getElementById('first').style.display = "none";
document.getElementById('second').style.display = "";
}
}
same else4
error....

undefined method `downcase' for ["aaaaa", "aaaa", ""]:Array

That's what rails does if two inputs have the same name: it only uses
the first one (unless the name ends with [], in which case you'll get
an array with all the values).

Fred

please help me....

my template is:
view.rhtml
<script>
function switchLogin(vendor) {
if(vendor=="first") {
document.getElementById('second').style.display = "none";
document.getElementById('first').style.display = "";
}
else if(vendor=="second") {
document.getElementById('first').style.display = "none";
document.getElementById('second').style.display = "";
}
}

</script>
<li><a href="#"><img src="../images/a.gif" title="First"
onclick="switchLogin('first');"/></a></li>
<li><a href="#"><img src="../images/b.gif" border="0" title="Second"
onclick="switchLogin('second');"/></a></li>
<form action="/a/create">
<div id="first">
<div><input type="text" name="empfirstname"/></div>
<div><input type="text" name="emplastname"/></div>
</div>
<div id="second">
<div><input type="text" name="empfirstname"/></div>
<div><input type="text" name="emplastname"/></div>
</div>
</form>

My controller is....

def create
  @firstname=params[:empfirstname]
  @lastname=params[:emplastname]
  @contacts = Contactbook.get :firstname => @firstname, :lastname =>
@lastname
  end

Enter <div id="first"> this div only working

But.... Second <div id="first"> not working

Not get values in second div

please help me.....

or

<form action="/a/create">
<div id="first">
<div><input type="text" name="empfirstname[]"/></div>
<div><input type="text" name="emplastname[]"/></div>
</div>
<div id="second">
<div><input type="text" name="empfirstname[]"/></div>
<div><input type="text" name="emplastname[]"/></div>
</div>
</form>
Through Error undefined method `downcase' for ["aaaaa", "aaaa",
""]:Array

Enter <div id="first"> this div only working

But.... Second <div id="first"> not working

Not get values in second div

please help me.....

or

<form action="/a/create">
<div id="first">
<div><input type="text" name="empfirstname[]"/></div>
<div><input type="text" name="emplastname[]"/></div>
</div>
<div id="second">
<div><input type="text" name="empfirstname[]"/></div>
<div><input type="text" name="emplastname[]"/></div>
</div>
</form>
Through Error undefined method `downcase' for ["aaaaa", "aaaa",
""]:Array

If you do this then params[:empfirstname] will be an array so you need
to handle it appropriately. I have no idea what you are doing but it
may be more appropriate to just disabled the inputs when you hide
their containing div.

Fred