کد HTML:
<!doctype html>
<html>
<head>
<script language="javascript">
var d=document;
function i(e){
if(d.all)
return d.all(e);
else if(d.getElementById)
return d.getElementById(e);
else
throw new Error('cannot find element');
}
function formating(){
var s='';
s='your textbox value is:'+i('txt_string').value+'\n';
s+='-------------------------------------\n';
if(i('choose1').checked)
s+='bg checkbox checked.\n';
if(i('choose2').checked)
s+='bold checkbox checked.\n';
if(i('choose3').checked)
s+='italic checkbox checked.\n';
if(i('choose4').checked)
s+='small checkbox checked.\n';
if(i('choose5').checked)
s+='strike checkbox checked.\n';
s+='-------------------------------------\n';
s+='your selected pull down menu is :'+i('pull').options[pull.selectedIndex].value+'\n'
s+='-------------------------------------\n';
s+='your selected pull down menu color is :'+i('pull').options[pull.selectedIndex].value+'\n';
s+='-------------------------------------\n';
s+='your selected pull down menu number is :'+i('num').options[num.selectedIndex].value+'\n';
alert(s);
}
کد HTML:
</script>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form border="12" id="f0">
string object formating
<hr>
string:<input type ="text" name="textbox" size=30 value="" id="txt_string">
<p>
style : <input type="checkbox" checked="checked" id="choose1" value="1" /> Big
<input type="checkbox" id="choose2" /> Bold
<input type="checkbox" id="choose3" /> Italic
<input type="checkbox" id="choose4" /> Small
<input type="checkbox" id="choose5" /> Strike
<p>
Font : color
<select name= "pull down menu color" id="pull">
<option>Red
<option>Green
<option>blue
</select>
size :
<select name= "pull down menu number" id="num">
<option>8
<option>10
<option>12
<option>14
<option>16
<option>18
<option>20
</select>
<p>
<input type="button" name="submit-button" value="Show" onclick="formating()">
</form>
</body>
</html>
امیدوارم مفید بوده باشه.....