大家好,这里是我的代码
echo('Name: <input type="text" id="Name" onchange="im()" value="your name" name="Name" />');
echo('pointsize: <input type="text" id="pointsize" onchange="im()" value="50" name="pointsize" />');
echo('format: <input type="text" id="format" value=".gif" onchange="im()" name="format" />');
echo('BackGround Color: <input type="text" id="bckclr" value="red" onchange="im()" name="bckclr" />');
echo('FontColor: <input type="text" id="color" value="white" onchange="im()" name="color" />');
echo('Border Color: <input type="text" id="bcolor" value="blue" onchange="im()" name="bcolor" />');
echo('<a href="./lang/ims.php"><img src="'.$image.'" height="82" width="82" /></a>');
echo('Font: <input type="text" id="font" value="'.$image1.'" onchange="im()" name="font" />');
echo ('<div id="Div_Im">');
echo('replace me');
echo ('</div>');
这是我的 AJAX 代码。
<Script type="text/javascript">
function im()
{
var Name=document.getElementById("Name").value;
var pointsize=document.getElementById("pointsize").value;
var format=document.getElementById("format").value;
var bckclr=document.getElementById("bckclr").value;
var color=document.getElementById("color").value;
var bcolor=document.getElementById("bcolor").value;
var font=document.getElementById("font").value;
$(document).ready(function(){
var url='Name='+Name+'&pointsize='+pointsize+'&format='+format+'&bckclr='+bckclr+'&color='+color+'&bcolor='+bcolor+'&font='+font;
alert(url);
//-----Sending request to server for getting job name list by ajax-----
$.ajax({
type : "POST",
url : "i.php?",
data : url,
cache : false,
success : function(html)
{
//document.getElementById('Div_PJobId').style.display="block";
//alert('hi');
alert(html);
var pic='<img src="'+html+'">';
$("#Div_Im").html(pic).show();
}
});
});
}
</script>
这是我的 i.php 服务器页面代码
$Name=$_POST["Name"];
$pointsize=$_POST["pointsize"];
$bckclr=$_POST["bckclr"];
$color=$_POST["color"];
$bcolor=$_POST["bcolor"];
$format=$_POST["format"];
//$filename = "./lang/sri".$format;
$filename = "./lang/".$Name.$format;
$font=$_POST["font"];
$cmd = " -background $bckclr -pointsize $pointsize -font $font -fill $color ".
" -strokewidth 1 -stroke $bcolor label:\"$Name\" ";
exec("convert $cmd $filename");
//if($filename)
//{}
//echo('<img src="'.$filename.'">');
echo $filename;
请查看演示链接。仅当我更改名称时,内容(显示在中的图像)才会替换,但它不适用于颜色、bcolor、字体,...每次更改时我都需要刷新页面...。解决这个问题的方法?