English 中文(简体)
Jquery val()总是先 gr的,不管选择什么东西。
原标题:Jquery val() always grabs first select value no matter which is selected

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>
最佳回答

执行该守则:

new AjaxUpload(btnUpload, {
    action: setWatermark(),
    name:  uploadfile ,
});

浏览器首先必须构造这些论点,以便转给施工商。 为了构造第二个论点,该标的必须是setWatermark,以获取>>>>>> 财产的价值。 这就是你的问题所在;在创建<条码>AjaxUpload标时,正在打电话到<条码>。

我不知道<代码>AjaxUpload是什么,但你不得不找到一种办法,在需要<编码>action<<>code>时,将其称作功能,而不是将其作为选项中的一种固定功能。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签