Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

860 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