Forum: Ruby on Rails please help forms...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
60bb25c88eda9e783e1d22653e26f86d?d=identicon&s=25 Smarty 2k (smartee)
on 2008-11-14 10:39
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.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-14 10:43
(Received via mailing list)
On Nov 14, 9:39 am, Smarty 2k <rails-mailing-l...@andreas-s.net>
wrote:
>
> Enter <div id="first"> this div only working
>
> But.... Second <div id="first"> not working
>
> Get only first div datas only....
> please help me...

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
60bb25c88eda9e783e1d22653e26f86d?d=identicon&s=25 Smarty 2k (smartee)
on 2008-11-14 10:51
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
60bb25c88eda9e783e1d22653e26f86d?d=identicon&s=25 Smarty 2k (smartee)
on 2008-11-14 11:13
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-14 11:53
(Received via mailing list)
On 14 Nov 2008, at 10:13, Smarty 2k wrote:
>
> 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
This topic is locked and can not be replied to.