Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 516
Location: London
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 11-24-2006, 03:13 PM Re: creating new element OPTION
Novice Talker

Posts: 9
Location: Russian Federation
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.27738 seconds with 12 queries