Im利用Jquery使用户能够以某种形式通过Ajax上载图像(在表格实际提交之前,图像上载重)。 我增加了在上载的每一图像上添加一个水标的能力(在上载上:image.php)。
用户可以选择他们希望通过选择的形式将水标放在其形象的地方。 使用Jquery s .val() gr取“水标志”的价值,选择并添加这一标记,作为将高载荷_image.php的加固值。
The problem is that it always passes the first select value no matter what I actually select in the form. I tried putting it in a function (thought it was grabbing the value on page load) no luck there. I changed the select to radio buttons. It still grabs the value of the first radio button on the page; no matter what you select.
本文所用文字部分是:
<script type="text/javascript" >
$(function(){
// build URL to php upload script with watermark placement
function setWatermark() {
var uploadUrl = http://www.mysite.com/upload_image.php?w= ;
var watermarkValue = $( #watermark ).val();
var watermarkUrl = uploadUrl + watermarkValue;
return watermarkUrl;
}
var btnUpload=$( #upload );
new AjaxUpload(btnUpload, {
action: setWatermark(),
name: uploadfile ,
});
});
</script>
这是形式(除去了无关的领域):
<form id="image_form" action="this_form.php" method="post" enctype="multipart/form-data">
<select id="watermark">
<option value="top_left">Top Left</option>
<option value="top_right">Top Right</option>
<option value="center">Center</option>
<option value="bottom_left">Bottom Left</option>
<option value="bottom_right">Bottom Right</option>
</select>
<div id="upload" ><span><img src="upload_button.jpg" /></span></div>
</form>