0

Is it possible to submit an entire dom object, values included? Assuming I have something like that:

<input type="text" name="name" id="name"
           value=""/>

Once the user enters it's name (for example, "my name", I'd like to receive the entire DOM object. so on the server I'll get

<input type="text" name="name" id="name"
           value="**My Name**"/>

I'm aware I can send the entire innerHTML but that doesn't provide me the values the user entered.

Yoni Moses
  • 173
  • 1
  • 13
  • 1
    You cannot really send the DOM object. You can create your own serialization of it (like HTML or JSON) and send it. Why do you want this? – Felix Kling Nov 01 '12 at 18:12

1 Answers1

0

It's weird as hell, but you could grab the whole body (or a portion via #id) using jQuery:

​$(function(){
   $('form').on('submit',function(e){
       e.preventDefault();
       var content = $('body').html();
       alert(content);
   });
});​
Fluidbyte
  • 5,162
  • 9
  • 47
  • 76
  • By the way, this code is jquery, in case anyone has any errors because they aren't including jquery. – Joshua Dwire Nov 01 '12 at 18:16
  • @jdwire - thanks for clarification, I was taken aback by the question and forgot to mention that. – Fluidbyte Nov 01 '12 at 18:17
  • The value attribute is not same as the value property... it's the same as the defaultValue property. The value property is not serialized to html because there is no corresponding attribute. See http://stackoverflow.com/questions/11778123/why-arent-some-technically-serializable-input-properties-serializable – Esailija Nov 01 '12 at 18:31