0

collecting data from formfields to append to the post script.

var dataString = 'name='+ name + '&company_name='+ company_name + '&adres='+ adres + '&zip='+ zip + '&city='+ city + '&email=' + email + '&phone=' + phone + '&message=' + message + '&imgs=' ;

But the last value imgs can be multiple values added trough an ajax upload script and is generated dynamicly i created a hidden form field, but dont know how to pass the hidden form vars to the datastring, who can help me out here?

//Add uploaded file to list
                if(response==="success"){
                    $('<li></li>').appendTo('#files').html('<input name="image" class="img" type="hidden" value="mailatt/'+file+'" /><img src="mailatt/'+file+'" alt="" width="300" /><br /><p>'+file+'</p>').addClass('success');
                } else{
                    $('<li></li>').appendTo('#files').text(file).addClass('error');
            }
1
  • have you tried this var dataString = $("#testform").serialize(); Commented Feb 9, 2011 at 13:23

1 Answer 1

1

Use jquery's serialize form:

$('form').submit(function() {
  alert($(this).serialize());
  return false;
});
Sign up to request clarification or add additional context in comments.

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.