String selected in list – replaces text on page

[Total: 0    Average: 0/5]

This example uses a select list to allow the user to pick a text string.

Body Code:

<!--
  -- This table is just a spacer
  -->
<table border=1><tr height=100><td width=300>&nbsp;</td></tr></table>
<script>
var isIE=document.all?true:false;
var isNS4=document.layers?true:false;
var isNS6=!isIE&&document.getElementById?true:false;
var _w = '';  
if (isNS4) _w = '<layer id=one name=one>STUFF</layer>';  
if (isIE||isNS6) _w = '<div id=one name=one>STUFF</div>';  
document.write(_w);  

function replaceIt(_v) {
//alert(document.HitCriteria[0].selectedIndex+"n"+document.HitCriteria[0].options[document.HitCriteria[0].selectedIndex].value);
var _n=document.HitCriteria[0].options[document.HitCriteria[0].selectedIndex].value;
if(_v)_n=_v;
if (isNS4) {
        document.one.document.open();  
        document.one.document.write(_n);  
        document.one.document.close();  
        }
if (isIE) { document.all.one.innerHTML=_n;}
if (isNS6) { document.getElementById("one").innerHTML=_n; }
}     
</script>  


<BR>  
<a href="javascript:replaceIt('hi there')">click me</a>  
 <FORM Name="HitCriteria"  METHOD="Get"> 
  <SELECT Name="DateRange"  LANGUAGE=javascript onchange="return replaceIt()"> 
   <OPTION VALUE="TODAY" SELECTED>TODAY</option>
   <OPTION VALUE="YESTERDAY">YESTERDAY</option>
   <OPTION VALUE="LAST WEEK" >LAST WEEK 
   <OPTION VALUE="THIS WEEK" >THIS WEEK 
   <OPTION VALUE="LAST MONTH">LAST MONTH  
   <OPTION VALUE="THIS MONTH">THIS MONTH 
   <OPTION VALUE="LAST YEAR">LAST YEAR 
   <OPTION VALUE="THIS YEAR">THIS YEAR 
   <OPTION VALUE="BETWEEN">BETWEEN 
  </SELECT> 
 </FORM>   

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *