You must use keyevents, something like this to get key events in specified
fields.

$("input").*keypress*(function (e) {
      if (e.which == 13) {

 } else if (e.which == 8) {
        // backspace in IE only be on keydown
        $("p").children
<http://docs.jquery.com/Traversing/children>(":last").remove
<http://docs.jquery.com/Manipulation/remove>();
      }
      $("div").text <http://docs.jquery.com/Attributes/text>(e.which);
    });



2009/12/6 Erdem <erde...@gmail.com>

> hi
> i have a form with submit button... ajax sending form value to my php
> page and showing results in same page...
> it is work perfect when click submit button but its going to my
> process php page when hit enter. i want ajax to make same when hit
> enter or click submit button.... btw thanks for spending time for
> answer me :)
>
> here my js file:
>
> $(function() {
>
>    var paraTag = $('input#submit').parent('p');
>    $(paraTag).children('input').remove();
>    $(paraTag).append('<input type="button" name="submit" id="submit"
> value="Translate!" />');
>
>    $('#main input#submit').click(function() {
>        $('#main').append('<img src="images/ajax-loader.gif"
> class="loaderIcon" alt="Loading..." />');
>
>        var from = $('select#from').val();
>        var to = $('select#to').val();
>                var word = $('input#word').val();
>
>        $.ajax({
>            type: 'post',
>            url: 'translate.php',
>            data: 'from=' + from + '&to=' + to + '&word=' + word,
>
>            success: function(results) {
>                $('#main img.loaderIcon').fadeOut(1000);
>                $('ul#response').html(results);
>            }
>        }); // end ajax
>    });
> });
>
>


-- 
Carlos De Oliveira
Departamento De Sistemas
Consultor Senior
0426 517 73 01
0212 204 69 60
cdeolive...@grupozoom.com
card...@gmail.com

Reply via email to