Jump to content

<select> not displaying properly


shaunmckinnon

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.