Reply
creating new element OPTION
Old 11-23-2006, 06:41 PM creating new element OPTION
numbenator's Avatar
Ultra Talker

Posts: 411
Location: London
HI

I have two selct lists

Code:
<select name="s1" id="s1">

  <option value="1">sample 1</optopn>
  <option value="2">sample 2</optopn>

</select>
Code:
<select name="s2" id="s2">

  <option value="3">sample 3</optopn>
  <option value="4">sample 4</optopn>

</select>
and a button

Code:
<input name="button"  type="image"  src="looseSub.gif" onclick="looseSubSection(); return false;">
I want my js function looseSubSection() to remove selected option from s1 and place in s2 and show that change on the page

I have been messing createElement but have had not joy. I've now read that createElement is not used in IE... I've been at this a couple of hours now and so thought some one could set me straight how to do.

Mych appreciated

steve
__________________
www.mastech-solutions.com
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
When You Register, These Ads Go Away!
Old 11-24-2006, 02:13 PM Re: creating new element OPTION
Novice Talker

Posts: 9
Location: Russian Federation
numbenator, try this function:
Code:
 
function looseSubSection(select1, select2) {
  var element = select1.options[select1.selectedIndex];
  select2.insertBefore(element, select2.firstChild);
  select2.selectedIndex = 0; 
}
And function call:
HTML Code:
<input type="button" onclick="looseSubSection(document.getElementById('s1'), document.getElementById('s2'));">
_ru_ is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to creating new element OPTION
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11331 seconds with 12 queries