0

how can pass the jquery var value to html input box

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

i am working on django i have dynamic add row function to add rows and then save it to db

1
  • You can simply append the value in string. value='"+m+"' /> Commented Mar 25, 2017 at 5:23

5 Answers 5

2

Try this,

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

This way you can assign m value to input having name phoneManufacturer

Sign up to request clarification or add additional context in comments.

Comments

1

U can Use Jquery Itself

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

if the name of input is unique then use

$("phoneManufacturer").val(m);

else add unique id to input

$("#someuniqueid").val(m)

$("table tbody").append(markup);

Comments

0

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

Comments

0

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

Comments

0

To set input box a value ( with Jquery ) like:-

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.