Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: list box formatting


Message #1 by "Magnus Tullock" <magnus.tullock@a...> on Tue, 6 Nov 2001 08:43:19
How are you adding options? What browsers are you targetting?

This works in IE 5+ and Netscape 6:


<html>
<head>
	<title>Add option</title>
	
	<script language="JavaScript" type="text/javascript">
    		function addOption(){
			var oOption = document.createElement("option");
			oOption.innerHTML = "&nbsp;&nbsp;Option three";
	
document.getElementById("optionSelect").appendChild(oOption);
	        }
	    </script>	
</head>

<body>


<select id="optionSelect" style="font-family:Verdana; font-size:10px">
	<option>Option one</option>
	<option>&nbsp;&nbsp;Option two</option>
</select>

<input type="button" value="Add Option" onClick="addOption()">

</body>
</html>


/Robert



-----Original Message-----
From: Magnus Tullock [mailto:magnus.tullock@a...] 
Sent: den 6 november 2001 13:21
To: javascript
Subject: [javascript] RE: list box formatting


the &nbsp; doesnt work either as I am wanting to update the list from 
Javascript and when I use either \t or &nbsp; I get black or white boxes 
respectivly 


> You can change the font with stylesheets:
> 
> <select style="font-family:Verdana; font-size:10px">
> 	<option>Option one</option>
> 	<option>Option two</option>
> </select>
> 
> To achieve tabs, you can can put &nbsp; before the text:
> 
> <option>&nbsp;&nbsp;Option one</option>
> 
> 
> /Robert
> 
> 
> 
> -----Original Message-----
> From: Magnus Tullock [mailto:magnus.tullock@a...] 
> Sent: den 6 november 2001 09:43
> To: javascript
> Subject: [javascript] list box formatting
> 
> 
> hey guys,
> is it possible to change the font in a list box and also to put a tab in 
> it as well (ie I would use the \t command in a text area)
> 
> cheers
> Magnus


  Return to Index