Mac Taylor
Mac Taylor

Reputation: 5148

how to update two input boxes in jquery

i create two input text fields , one for title and another for permanent link

i need to update the second filed automatically when user is typing the tilte

how can i do such a thing in jquery /php

somehow im looking for a way to simulate wordpress creation of permanent link in post section

Upvotes: 4

Views: 196

Answers (3)

jAndy
jAndy

Reputation: 236022

$('#first_input_id').bind('keydown', function(e){
     var inputmirror = $('#second_input_id');
     inputmirror.val(inputmirror.val() + String.fromCharCode(e.which));
});

Something similar to this should do it.

Upvotes: 3

mamoo
mamoo

Reputation: 8166

You can intercept keyup event on the first input text, and then update the output of the second input:

    $('#titleInput').keypress(function(e) { alert ('typed' + String.fromCharCode(e.keyCode))//update your 2nd input text... 
}

Upvotes: 0

Quentin
Quentin

Reputation: 943605

Write a function to read from the current input, munge it however you like, and insert it into the other input.

Then bind that function to the keypress and change events.

Upvotes: 0

Related Questions