Solved

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

Posted on 2012-03-28
4
287 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

914 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

22 Experts available now in Live!

Get 1:1 Help Now