تغییرات با استفاده از جاوا اسکریپت
سلام دوستان
من یه فرم میخواستم درست کنم که اگر روی دکمه show کلیک کردم اعمال تغییر رنگ وسایز و.. رو که علامت زدم نشون بده ام به جاوااسکریپت خیلی مسلط نیستم
میشه راهنماییم کنید یخورده برای یاد گیری میخوام
کد HTML:
<head>
<script type="text/javascript">
function formating(){
alert ("?? ????? ???? ??????? ??? ?????");}
</script>
</head>
<body><form border="12">
string object formating
<hr>
string:<input type ="text" name="textbox" size=30 value="aaa ">
<p>
style : <input type="checkbox" checked="checked" name="choose1" value="1" /> Big
<input type="checkbox" name="choose2" onclick="formating()" /> Bold
<input type="checkbox" name="choose3" /> Italic
<input type="checkbox" name="choose4" /> Small
<input type="checkbox" name="choose5" /> Strike
<p>
Font : color
<select name= "pull down menu">
<option>Red
<option>Green
<option>blue
</select>
size :
<select name= "pull down menu">
<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:
<!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>
امیدوارم مفید بوده باشه.....
نقل قول: تغییرات با استفاده از جاوا اسکریپت
درست نشد:اشتباه::اشتباه::اشتباه:
نقل قول: تغییرات با استفاده از جاوا اسکریپت
ممنونم
من خواستم اگر رنگ یاسایزیا .. را انتخاب کردم متن داخل text box به اون رنگ وسایزو.. دربیاد البته با زدن دکمه show
ممنون میشم اگه بمن توضیح بدین چکار کنم
مناین کد رو نوشتم بازدن دکمه show رنگ متن نارنجی میشه
من میخوام براساس تگselect
, option هاش یعنی قرمز وسبز وآبی ااعمال بشه
کد HTML:
<!doctype html>
<html>
<head>
<script type="text/javascript">
function ChangeColor(id)
{
var block = document.getElementById('txt_string');
block.style.color= "#FC0";
}
</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>