Pad Option Values

S

Steve Bishop

Is it possible to use a function to pad option values in a drop down
box? I need to pad 5 values in a drop down box 15 characters with balnk
spaces then add a "1" on the end. Code example appreciated. Thanks
Steve



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
L

Lasse Reichstein Nielsen

Steve Bishop said:
Is it possible to use a function to pad option values in a drop down
box? I need to pad 5 values in a drop down box 15 characters with balnk
spaces then add a "1" on the end.

By padding, do you mean padding to 15 characters or by 15 characters.
I'll assume "to", as that is the (marginally) hardest.
Code example appreciated. Thanks

---
function padSelect(selectRef) {
var options = selectRef.options;
for (var i=0; i<options.length; i++) {
var value = options.value;
value += " ".substring(value.length) + "1";
options.value = value;
}
}
---

Call as:

---
padSelect(document.forms['formId'].elements['selectName']);
---

(not tested)

Good luck
/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top