Reputation: 11341
Here are the snippets from one of our pages. It's my opinion that this is terribly complex, confusing, and flawed in it's design. For one thing, it causes a message in IE that the page is trying to access the clipboard. Is there something I'm missing?
I guess my question is; Is it okay to think that this is complete overkill? Do I have a right to be frustrated? Or am I oblivious to some higher knowledge?
function NoEmailGiven(){
var copyval
document.frm1.NoEmail.focus();
document.frm1.NoEmail.select();
copyval=document.SCPACALL.NoEmail.createTextRange();
copyval.execCommand('Copy');
document.frm1.Email1.focus();
document.frm1.Email1.select();
document.execCommand('Paste');
document.frm1.Email2.focus();
document.frm1.Email2.select();
document.execCommand('Paste');
}
response.write "<INPUT TYPE=button name=NoEmail VALUE=""None"" Title=""Click if No Email Address"" ONCLICK=""NoEmailGiven""></td></tr>"
If the user clicks the button labeled "Click here if no email address" then auto populate Email1 & Email2 with the literal string 'None'
If the user clicks the button labeled "Click here if no email address" copy the value of this button which is "None" into the client's clipboard, then paste from the clipboard into Email1 & Email2
Finally: What I would have written (Only to duplicate the process, not improve or change the form to the users)
function NoEmailGiven()
{
Email1.value = "None";
Email2.value = "None";
}
Upvotes: 1
Views: 68
Reputation: 72965
Yes, this is a stupid way to do this. They obviously didn't know what they were doing and have not realised that copy and paste is a user orientated concept, whereas copying the value of one field to another using code more sense.
I'd delete it and rewrite it!
Upvotes: 3
Reputation: 37506
I'm assuming that what they're trying to do is copy data from one field to another. In jQuery, that would be:
var NO_EMAIL = '.....';
function NoEmailGiven() {
$('#Email1').val(NO_EMAIL);
$('#Email2').val(NO_EMAIL);
}
Upvotes: 0