469,343 Members | 5,478 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

Pad Option Values

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!
Jul 23 '05 #1
1 1173
Steve Bishop <st****@viper.com> writes:
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[i].value;
value += " ".substring(value.length) + "1";
options[i].value = value;
}
}
---

Call as:

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

(not tested)

Good luck
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Harlin Seritt | last post: by
9 posts views Thread by Ritesh Raj Sarraf | last post: by
1 post views Thread by Stephen D Cook | last post: by
4 posts views Thread by magix | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.