SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Jquery keyup

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    East of Ottawa, ON
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery keyup

    How can I make the keyup event work for all of the variables?

    I works with salutation but not first.

    Code JavaScript:
    $(document).ready(function(){
     
       var initial = $('#Initial');
       var salutation = $('#Salutation');
       var first = $('#FirstName');
       var last = $('#LastName');
       var title = $('#Title');
       var nametag = $('#Name');
     
       $(salutation, first).keyup(function(){
    	{
    	   var copy = salutation.val();
    	   copy += first.val() + " ";
    	   copy += initial.val() + " ";
    	   copy += last.val() + " ";
    	   copy += title.val() + " ";
    	   nametag.val(copy)
       });
    });

  2. #2
    SitePoint Zealot Gar onn's Avatar
    Join Date
    Feb 2011
    Location
    Belgium
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you do this:
    Code JavaScript:
       $("#Salutation , #FirstName").keyup(function(){

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    East of Ottawa, ON
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found another solution.

    Code JavaScript:
    var initial = $('#Initial');
    var salutation = $('#Salutation');
    var first = $('#FirstName');
    var last = $('#LastName');
    var title = $('#Title');
    var nametag = $('#Name'); 
     
    var controls = $('#Initial, #Salutation,#Firstname');
     
    $(controls).keyup(function(){


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •