?
Solved

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

Posted on 2012-03-28
4
Medium Priority
?
296 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 1000 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…
Suggested Courses

765 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