Ruby on Rails Wednesday, November 18, 2015

Hi

On Monday, 16 November 2015 13:10:13 UTC, Ruby-Forum.com User wrote:
 
I want to change the value of a field when another field is updated.

Specifically, I want my e mail field to get it's data from the username,
the domain always being the same, so username is say johndoe, e mail
address will be joh...@wherever.com

my fields look like this:

    <p><h3><label class="field" for="username">Username:</label></h3>
    <%= f.text_field :username, :style => "width: 250px" %></p>

    <p><h3><label class="field" for="email">Email Address:</label></h3>
    <%= f.text_field  :email, :style => "width: 250px" %></p>

Very much a beginner with JavaScript incidentally so be gentle

Do you really need to do this with Javascript?

As someone else has said, if the domain is always the same then you only really need to ask for the username.  If you want to store the full email address in your database you could add it on server-side in your ruby code (if you're using Rails then as a before_save callback on the model)

 
Help is very much appreciated.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/916e1a49-40c0-4a41-851e-dfac1ce63ed7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment