Debt Consolidation - Debt Consolidation - Wordpress Themes - Credit Card - Sport Betting Systems

PDA

View Full Version : form


dean5000v
Feb 20th 2009, 2:32 am
myTextField.id = 'myTextField';
myTextField.name = 'myTextField';
myTextField.style.width = '200px';
myTextField.onkeyup = 'example';


hey im creating form feilds with javascript for some reason i can change the onkeyup value does anyone know what i am doing wrong ??

dean5000v
Feb 20th 2009, 3:29 am
sorry for double posting here is my code:

var myTextField = document.createElement('input');
myTextField.type = 'text';
myTextField.id = 'myTextField';
myTextField.name = 'myTextField';
myTextField.style.width = '200px';

document.body.appendChild(myTextField);


i just cnt figure out for the life of my how to add the event onkeyup via javascript rather than creating it in html manually >

gnp
Feb 20th 2009, 6:02 am
you need to reference the function by its name if it is defined... (Not as a string though)

so
myTextField.onkeyup = 'example';
should be (if you have a function named example)
myTextField.onkeyup = example;

alternatively you can define on the fly a function for it like this
myTextField.onkeyup = function(){
alert('keyup fired ;)');
// any code you like here...
};

take care