简体   繁体   English

如何将jQuery varibale值传递给html输入框?

[英]How to pass jquery varibale value to html input box?

how can pass the jquery var value to html input box 如何将jquery的var值传递给html输入框

var m = $("#id_manufacturer").val();
var markup = "<tr><td><input type='checkbox' name='record'></td><td><input type='text' name='phoneManufacturer' value=m/></td></tr>
$("table tbody").append(markup);

this my code i want pass var m value to input box which i want to save into db via post method 这是我的代码,我想将var m值传递给输入框,我想通过post方法将其保存到db中

i am working on django i have dynamic add row function to add rows and then save it to db 我正在使用django,我具有动态添加行功能以添加行,然后将其保存到数据库

To set input box a value ( with Jquery ) like:- 要设置输入框一个值(使用Jquery),例如:

<input type="text" value="" id="myInput">

<script>
   var myVal=78; $('#myInput').val(myVal);
</script>

Try this, 尝试这个,

var m = $("#id_manufacturer").val();
$("input[name='phoneManufacturer']").val(m);

This way you can assign m value to input having name phoneManufacturer 这样,您可以将m值分配给名称为phoneManufacturer输入

U can Use Jquery Itself 你可以自己使用Jquery

var m = $("#id_manufacturer").val(); var m = $(“#id_manufacturer”)。val(); var markup = " var markup =“

if the name of input is unique then use 如果输入的名称是唯一的,则使用

$("phoneManufacturer").val(m); $(“ phoneManufacturer”)。val(m);

else add unique id to input 否则添加唯一的ID到输入

$("#someuniqueid").val(m) $(“#someuniqueid”)。val(m)

$("table tbody").append(markup); $(“ table tbody”)。append(markup);

Try this: 尝试这个:

var markup = '<tr><td><input type="checkbox" name="record"></td><td><input type="text" name="phoneManufacturer" value="' + m + '"/></td></tr>';

Explanation: concatenation of m in the value attribute of text 说明:textvalue属性中串联m

var m = $("#id_manufacturer").val(); var m = $(“#id_manufacturer”)。val(); $("input[name='phoneManufacturer']").val(m); $(“ input [name ='phoneManufacturer']”)。val(m);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 class 值从 jquery 传递到输入框 - How to pass class value from jquery into input box jQuery-将值从输入框传递到另一个页面的输入框 - JQuery - Pass value from an input box to a input box in another page 如何将一个输入框中的值传递给另一个输入框 - How Do I pass a value in a input box, to another input box 将HTML输入值传递给jQuery表单值 - Pass HTML input values to jQuery form value 如何将文本框输入字段的值传递给 jQuery 中单选按钮的值 - How to pass the value of a text box input field to the value of a radio button in jQuery 如何将 PHP 变量值从外部 PHP 文件传递​​到 html 输入框? - How to pass PHP variable value to html input box from external PHP file? 如何通过jquery / PHP中的post传递选项字段的值以及输入框? - How to pass the value of an option field as well as an input box via post in jquery/PHP? 如何在我的HTML输入框中将VBScript字符串传递为默认值? - How can I pass a VBScript string to be the default value in my HTML input box? 如何将输入框(html 文件)中的值传递给 javascript 注入文件(inject.js)? - How can I pass a value from an input box (html file) to a javascript inject file (inject.js)? 如何使用jQuery判断输入框是否有值? - How to use jQuery to determine if there is a value in the input box?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM