setting the value of a text input

This is starting to get on my nerves. I’m trying to set the value of text inputs on a form so I can submit it to a database. I’ve tried using .val() and re-rendering the tag completely. I use firebug to debug code, and while it shows the proper information in there, if I view the source code, the value is empty.

form code

Label Name:

js response
$("#labelname").attr(“value”, result.label).val(result.label);

from what I’ve read, attrib is supposed to change the value and val puts in the box. It shows on the screen, but not in the physical code. So when I go to submit it, I get a bunch of empty fields and lots of errors because of that.

Is there something i’m doing wrong here?

Here is a working demo

if (!empty($_POST[‘text1’])) {
foreach ($_POST as $key => $var) {
$array[] = array(
‘name’ => $key,
‘value’ => $var . " 123"
header(‘Content-type: application/json’);
echo json_encode($array);


yea I got this working, didn’t realize I needed to have the name in there. I was going off of the id.

any idea what this means though?

Use of attributes’ specified attribute is deprecated. It always returns true.
error source line:
$("#submit_suc").toggle(‘fast’, function() {

I’m using jquery 2.0.3, but I use that stuff in other scripts with no problem, but in this instance, I can see the box expanding (because everything else is being shoved down), but the box isn’t actually becoming visible. Maybe I need to set the css attribute instead?

Sponsor our Newsletter | Privacy Policy | Terms of Service