Solved

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

Posted on 2012-03-28
4
285 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
  • 2
4 Comments
 
LVL 13

Expert Comment

by:ansudhindra
Comment Utility
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
Comment Utility
<!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
Comment Utility
@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
Comment Utility
"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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now