javascript - 如何在 Javascript 中获取输入字段的值

标签 javascript html jquery

我正在使用 value-file-uploader 插件。它允许我使用ajax上传文件。我有一个问题。我有以下脚本-

<input type="text" id="Gaurav" name="Gaurav" />
<script src="fileuploader.js" type="text/javascript"></script>
<script>
    function createUploader(){
        var uploader = new qq.FileUploader({
            element: document.getElementById('file'),
            action: 'do-nothing.php',
            params:{param: document.getElementById('Gaurav').value},
            allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
            minSizeLimit: 1,
            debug: false
        });
    }

    // in your app create uploader as soon as the DOM is ready
    // dont wait for the window to load  
    window.onload = createUploader;     
</script>

在其中,我想设置用户输入的参数值。该代码对于 Gaurav 的默认值可以正常工作,但对于用户输入的值不起作用。

最佳答案

您需要在用户输入值后调用createUploader该代码在窗口加载后立即“修复”参数值。

您可能有一个按钮单击事件或其他事件 - 从中​​调用它,它将采用当时的值...

关于javascript - 如何在 Javascript 中获取输入字段的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11672549/

相关文章:

javascript - jquery 在 Internet Explorer 中不可用

javascript - 查询 Sequelize 模型以匹配多个关联

javascript - 表单发布不接受链接

javascript - 使用 XMLHttpRequest 将多个文件上传到 Express.js 3.5 服务器

html - 在 iOS 电子邮件中禁用地址格式

javascript - JS 循环内循环

javascript - 加载或创建字段时 JQuery 输入掩码失败

javascript - 在具有相同配置的多个 Angular 应用程序中外部化服务配置

javascript - 点击时动画进度条

javascript 在 jQuery 之前加载 准备好了吗?