Put a value inside the 'val' of jquery [closed]

0

What is the right way to mount this line?

$("#rastreo").val('BR'<?php echo date("hYmdi"); ?>json[0].estado);

The crawl ID is an input field.

    
asked by anonymous 28.09.2015 / 19:43

2 answers

3

Remember that to concatenate strings with js , the '+' character is used. So your original code would look like:

$("#rastreo").val('BR'+<?php echo date("hYmdi"); ?>+json[0].estado);

An alternate form can be:

$('#rastreo').attr('value', 'BR'+<?php echo date("hYmdi"); ?>+json[0].estado);
    
28.09.2015 / 20:01
0

If it is a input you should do it this way:

$("#rastreo").val('TESTE');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype="text" id ="rastreo"> </input>

In case it's the same way you're doing today. So I believe the problem is in:

<?php echo date("hYmdi"); ?>json[0].estado
    
28.09.2015 / 19:47