Solved

how to change the span tag to have the value of the drop down

Posted on 2012-03-28
4
291 Views
Last Modified: 2012-03-30
I have a drop down and want to change the value of the span tag<span id="value"> ${document.subscriptionForm.FREQUENCYTYPE.value} </span> to the selected drop down value. for example if daily is selected i want "days" to appear as value in span tag
<td align="top">
<select id="FREQUENCYTYPE" name="FREQUENCYTYPE">
<option value="NONE">---Select Option---</option>
<option value="days">Daily</option>
<option value="weeks">Weekly</option>
<option value="fortnight">Fortnightly</option>
<option value="months">Monthly</option>
<option value="quater">Quaterly</option>
<option value="annual">Annually</option>
</select>
</td>

<tr height="25">
 <td align="left">
 <select name="FREQUENCYCOUNTTYPE" id="FREQUENCYCOUNTTYPE" onchange="disable_input()">
<option value="1" onclick="javascript:document.getElementById('txt').style.display='none';document.getElementById('value').style.display='none'">Never Ending</option>
<option value="2">Ending</option>
</select>
</td>
<td><span id="txt"> in </span></td>
 <td align="right">
<input disabled="disabled" type="text" size="10" name="FREQUENCYCOUNT" id="FREQUENCYCOUNT" />
</td>
 <td><span id="value"> ${document.subscriptionForm.FREQUENCYTYPE.value} </span>/td>
</tr>
0
Comment
Question by:Newton21205
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Expert Comment

by:ansudhindra
ID: 37780522
Check this..

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Demo</title>
  
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>

  <style type='text/css'>
    
  </style>
  


<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$('#FREQUENCYTYPE').change(function(){
    $('#value').html($(this).val());
});
});//]]>  

</script>


</head>
<body>
  <select id="FREQUENCYTYPE" name="FREQUENCYTYPE">
<option value="NONE">---Select Option---</option>
<option value="days">Daily</option>
<option value="weeks">Weekly</option>
<option value="fortnight">Fortnightly</option>
<option value="months">Monthly</option>
<option value="quater">Quaterly</option>
<option value="annual">Annually</option>
</select>

<br>

Selected Value : <span id="value"></span>
  
</body>
</html>

Open in new window

0
 
LVL 20

Assisted Solution

by:chaitu chaitu
chaitu chaitu earned 250 total points
ID: 37780523
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script>
  function changeFrequencyType(value)
  {

	if(value == 'days')
	{
		document.getElementById("value").innerHTML=value;
	}

  }
  </script>
 </head>

 <body>
<select id="FREQUENCYTYPE" name="FREQUENCYTYPE" onchange='changeFrequencyType(this.value)'>
<option value="NONE">---Select Option---</option>
<option value="days">Daily</option>
<option value="weeks">Weekly</option>
<option value="fortnight">Fortnightly</option>
<option value="months">Monthly</option>
<option value="quater">Quaterly</option>
<option value="annual">Annually</option>
</select>
</td>

<tr height="25">
 <td align="left">
 <select name="FREQUENCYCOUNTTYPE" id="FREQUENCYCOUNTTYPE" onchange="disable_input()">
<option value="1" onclick="javascript:document.getElementById('txt').style.display='none';document.getElementById('value').style.display='none'">Never Ending</option>
<option value="2">Ending</option>
</select>
</td>
<td><span id="txt"> in </span></td>
 <td align="right">
<input disabled="disabled" type="text" size="10" name="FREQUENCYCOUNT" id="FREQUENCYCOUNT" />
</td>
 <td><span id="value">  </span></td>
</tr>
 </body>
</html>

Open in new window

0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 250 total points
ID: 37780592
@chaituu and if it is NOT days?

I think you mean

function changeFrequencyType(value)   {
  document.getElementById("value").innerHTML=(value=="NONE")?"":value;
}
0
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 37780622
"for example if daily is selected i want "days" to appear as value in span tag "

i thought only for "days"  value span should be displayed.i have not read Q properly.TQ for correcting it.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question