حذف كوتيشن در تولد تگ رنگ

BetaMaster

Member
باسلام


در دستور زير :


PHP:
			//Size
			if (document.getElementById("qualityselect").value != ""){
			txt = "";
			txt += "[align=center][b]";
				if (document.getElementById("msize").value != ""){
			txt += "[color=\"" + document.getElementById("firstcolor").value + "\"]Size: [/color] [color=\"" + document.getElementById("secondcolor").value + "\"]";
			txt += document.getElementById("msize").value;
			txt += " ";
			txt += document.getElementById("sizeselect").value;
			txt += "[/color] | [color=\"" + document.getElementById("firstcolor").value + "\"]Quality:[/color] [color=\"" + document.getElementById("secondcolor").value + "\"]";
			txt += document.getElementById("qualityselect").value;
				}else{
			txt += "[color=\"" + document.getElementById("firstcolor").value + "\"]Quality:[/color] [color=\"" + document.getElementById("secondcolor").value + "\"]";
			txt += document.getElementById("qualityselect").value;
				}
				if(document.getElementById("year").value != ""){
			txt += "[/color] | [color=\"" + document.getElementById("firstcolor").value + "\"]Year:[/color] [color=\"" + document.getElementById("secondcolor").value + "\"]";
			txt += document.getElementById("year").value;
			txt += "[/color][/b][/align]\n";
			document.getElementById("gen").value += txt;
				}else{
			txt += "[/color][/b][/align]\n";
			document.getElementById("gen").value += txt;
				}
			}


بخش زير :

PHP:
[color=\"" + document.getElementById("firstcolor").value + "\"]


تگي بصورت زير ايجاد مي گكند :

PHP:
[color="#0044FF"]


در رشته دستوري ذكر شده چكاري بايد انجام دهم كه تگ بدون كوتيشن (") ايجاد كند (يعني بصورت زير ) ومشكل كار از كجاست كه با كوتيشن تگ مي سازد ؟:neutral:


PHP:
[color=#0044FF]



با تشكر
 

firebird

Member
اولاً این کد JavaScript هتست، نه php. ثانیاً شما "\ های داخل رشته ها رو که حذف کنی " ها هم حذف میشن. در JavaScript وقتی میخواهید " رو داخل یک رشته که بین "" هست، بذارید باید یک علامت \ قبل از اون قرار بدید تا بفهمه که اینجا رشته تموم نمیشه.
 

BetaMaster

Member
ممكنه يه نمونه اصلاح رو با مثال ( مثل خودم كه توضيح دادم) بذاريد ؟

من هر كاري مي كنم بهم مي خوره !
 

NabiKAZ

Well-Known Member
جناب firebird جواب دادند که:
شما "\ های داخل رشته ها رو که حذف کنی " ها هم حذف میشن.


HTML:
            //Size
            if (document.getElementById("qualityselect").value != ""){
            txt = "";
            txt += "[align=center][b]";
                if (document.getElementById("msize").value != ""){
            txt += "[color=" + document.getElementById("firstcolor").value + "]Size: [/color] [color=" + document.getElementById("secondcolor").value + "]";
            txt += document.getElementById("msize").value;
            txt += " ";
            txt += document.getElementById("sizeselect").value;
            txt += "[/color] | [color=" + document.getElementById("firstcolor").value + "]Quality:[/color] [color=" + document.getElementById("secondcolor").value + "]";
            txt += document.getElementById("qualityselect").value;
                }else{
            txt += "[color=" + document.getElementById("firstcolor").value + "]Quality:[/color] [color=" + document.getElementById("secondcolor").value + "]";
            txt += document.getElementById("qualityselect").value;
                }
                if(document.getElementById("year").value != ""){
            txt += "[/color] | [color=" + document.getElementById("firstcolor").value + "]Year:[/color] [color=" + document.getElementById("secondcolor").value + "]";
            txt += document.getElementById("year").value;
            txt += "[/color][/b][/align]\n";
            document.getElementById("gen").value += txt;
                }else{
            txt += "[/color][/b][/align]\n";
            document.getElementById("gen").value += txt;
                }
            }
 

جدیدترین ارسال ها

بالا