Editing two fields at the same time
I want to be able to edit the title of an article which is duplicated in a field called "url" which is updated in real time when the user types in the title field...how do I go about this?
开发者_如何学编程Thanks
You could use jQuery. Have a look at the Manual.
$(function()
{
$('#field1').keyPress(function()
{
$('#field2').val($(this).val());
});
});
Working demo: http://jsfiddle.net/Wcp3D/
$("document").ready(function ($) {
$("input").bind('keyup', function() { $("lable").text($(this).val()) } );
});
<input type='text'/>
<label></label>
do you mean something like this?
I don't have my environment configured here at work, but it should be something like that:
$("#url").change(function() {
document.title = $(this).value();
});
Add a function to the change-event of field one, and update field two in that function:
$('#field1').change( function( ) {
$('#field2').value( $(this).value( ) );
}
精彩评论