|
|
Subject:
White space in javascript created form elements under NS
Category: Computers > Programming Asked by: padders-ga List Price: $2.00 |
Posted:
01 Nov 2002 05:50 PST
Expires: 01 Dec 2002 05:50 PST Question ID: 95276 |
Hi there, I am creating some select menu form elements using javascript. There are in a category depth format like > category > > sub category > > > sub category 1. however I don't want to use > i want to just use white space. This works fine under IE, (using just a space) but does not work in NS (spaces seem to be ignored). I have tried but that is just displayed as the characters and not the HTML entity. Any ideas? | |
| |
| |
|
|
Subject:
Re: White space in javascript created form elements under NS
Answered By: hammer-ga on 01 Nov 2002 08:08 PST Rated: |
Hi Padders, You need to get a little tricky to get this past both the HTML interpreter *and* the JavaScript parser. 1. Place a hidden field on your form. 2. Set the hidden field's value to the number of spaces, using , that you want to use as a pad 3. Concatenate the hidden field's value into the text you pass to the new Option call. Here is sample code illustrating this technique: <html> <head> <script language="javascript"> function add_element() { var new_op; new_op = "the" + document.something.whacko.value + "value"; var newOption = new Option(new_op, "the value"); document.something.drop.options[0] = newOption; } </script> </head> <body> <form name="something"> <input type="hidden" name="whacko" value=" "> <select name="drop"> </select> </form> <a href="javascript:add_element();">click here</a> </body> </html> I tested this on IE5 and Netscape6. Both handled it properly. Please post if you need further clarification on this. Good luck! Hammer | |
| |
|
padders-ga
rated this answer:
and gave an additional tip of:
$1.00
Brilliant, answered question perfectly on something i had been unable to work out. |
|
Subject:
Re: White space in javascript created form elements under NS
From: blader-ga on 01 Nov 2002 05:54 PST |
Padders: Have you tried inserting an underscore character and using HTML code to set the font color of the underscore to match the background color? I'm not sure if this is feasible without looking at you source, so this is a comment. If this works, let me know and I'll post it as an official answer. |
Subject:
Re: White space in javascript created form elements under NS
From: padders-ga on 01 Nov 2002 06:49 PST |
HTML code does not work inside an option element. I also don't think you can use CSS to change the colour of only some elements in an option and not others. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |