Need help with Gmail username dropdown script
|
|
Hai, Im Neewb. This is a script Im working on for teh Gmail login page. The first part removes the "username" textbox, and then the second part adds a dropdown with a couple of user IDs for the user to choose. I just need the help on last line. Can't get it right next to the "Username: " text ?? var txtbx = document.getElementById('Email');
if (txtbx) {
txtbx.parentNode.removeChild(txtbx);
}
var target = document.getElementById("Passwd");
if (target) {
var dpdwn = document.createElement('select');
dpdwn.setAttribute('name', 'Email');
dpdwn.setAttribute('id', 'Email');
dpdwn.setAttribute('class', 'gaia le val');
dpdwn.setAttribute('size', '1');
var opt = document.createElement('option');
opt.setAttribute('value', 'john.doe');
var optxt = document.createTextNode('john.doe');
opt.appendChild(optxt);
dpdwn.appendChild(opt);
var opt = document.createElement('option');
opt.setAttribute('value', 'jane.doe');
var optxt = document.createTextNode('jane.doe');
opt.appendChild(optxt);
dpdwn.appendChild(opt);
target.parentNode.insertBefore(dpdwn, target.previousSibling); // ? ? ? ? ?
}
|
|
|
This script actually already works. I just need the created <select> element right next to the "Username:" text. Right now it shows a space and it looks ugly so its more of a cosmetic issue.</select> |
|
|
Wait, I forgot, I looked at one of my scripts and remembered this:
|
|
|
how's this for the script?
//add users through the array variable
var users = ['john.doe', 'jane.doe'];
var txtbx = document.getElementById('Email');
var target = document.getElementById('Passwd');
if (target) {
var dpdwn = document.createElement('select');
dpdwn.setAttribute('name', 'Email');
dpdwn.setAttribute('id', 'Email');
dpdwn.setAttribute('class', 'gaia le val');
dpdwn.setAttribute('size', '1');
dpdwn.setAttribute('style', 'width:' + target.offsetWidth + 'px');
function populate() {
for(var i = 0; i < users.length; i++) {
var opt = document.createElement('option');
opt.setAttribute('value', users[i]);
var optxt = document.createTextNode(users[i]);
opt.appendChild(optxt);
dpdwn.appendChild(opt);
}
}
populate();
}
if (txtbx) {
txtbx.parentNode.replaceChild(dpdwn, txtbx);
}
i hope this helped? |
|
|
Yeah, good job. Thanks, I credited you guys on the script page. |
