shaunmckinnon Posted July 3, 2008 Share Posted July 3, 2008 when I parse it shows in firefox the select box, but won't let it be selectable. in explorer it just shows AMPM side by side with now select box. Can't figure out what I've done wrong. Here's the code: <html> <head> <title>test</title> <script> function createTimeSelect(id){ document.getElementById(id).innerHTML="" +"<input type='text' id='' name='' value='hour' size='6'>" +":" +"<input type='text' id='' name='' value='minutes' size='6'" +"<select id='' name=''>" +"<option value=''>AM</option>" +"<option value=''>PM</option>" +"</select>"; } </script> </head> <body> <span id="timeSelectField" onClick="createTimeSelect(this.id);">***click here to select the time***</span> </body> </html> Thanks, Shaun Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 3, 2008 Share Posted July 3, 2008 Your second input tag isn't closed: +"<input type='text' id='' name='' value='minutes' size='6'" Should be: +"<input type='text' id='' name='' value='minutes' size='6'"> Quote Link to comment Share on other sites More sharing options...
shaunmckinnon Posted July 3, 2008 Author Share Posted July 3, 2008 sorry, i fixed that. it's still doing the same thing now in both firefox and internet explorer. it shows the select box but when you attempt to make a selection it closes the box on you and doesn't allow it. in fact when you click the arrow, the drop down box recede's immediately. Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 3, 2008 Share Posted July 3, 2008 I think it might be because you have the name of the select object set to some kind of blank string. Try giving it an actual name and see if it works better (Try with the values for the options, too.). Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted July 3, 2008 Share Posted July 3, 2008 Thats because you already have a click event on the div which is re-writing it again your code should be <html> <head> <title>test</title> <script> var createItem = 0; function createTimeSelect(id){ if (createItem==0) { document.getElementById(id).innerHTML="" +"<input type='text' id='' name='' value='hour' size='6'>" +":" +"<input type='text' id='' name='' value='minutes' size='6'" +"<select id='test' name='test'>" +"<option value=''>AM</option>" +"<option value=''>PM</option>" +"</select>"; createItem=1; } } </script> </head> <body> <span id="timeSelectField" onClick="createTimeSelect(this.id);">***click here to select the time***</span> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.