jquery - onkeyup - replace input and copy to another input
The old inline js code looked like this:
onchange="alias_generator(this,document.forms['category_form'].alias)" onkeyup="alias_generator(this,document.forms['category_form'].alias)"
This just means: copy from the 1. input (title) (this) ... filter it with the alias_generator (that removes special character) and move it to the 2. input (alias).
i'am new to jquery and external js - would be great if so开发者_如何学JAVAmeone can help me with that.
allready did some that works onload, but does not update...
var title = document.forms['admin'].title;
var alias = document.forms['admin'].alias;
alias_generator(title,alias);
$(".myInputFieldClass").keyup(
function(){
cur_val = $(this).val(); // grab what's in the field
// do stuff with cur_val so that it's what you want
$(this).val(cur_val);
}
);
That should do it. Good luck.
$(document.forms["admin"].title).keyup(function (e) {
var val = $(this).val();
// Do stuff with val
$(document.forms["admin"].alias).val(val);
})
精彩评论