0

I'm using jQuery to send an HTML document which contains a form to a C# WebService. The webService parse it and try to read "value" attribute of all inputs in the form.

The problem is that I send the HTML doc to the webservice with

var HTMLDoc = document.getElementById('foo').innerHTML;

And it does not returns the input with value attribute. For example, I got a :

<input type="text" id="foo" />

And I want the JavaScript to get :

<input type="text" id="foo" value="bar" />

when I do something like

document.getElementById('foo').innerHTML;

Is this possible ? Any idea ?

2 Answers 2

1

you can try it

HTML

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

in Jquery :

var foo = $("#foo").val();
alert("Jquery foo value : " + foo);

in JavaScript :

var foo = document.foo.value;
alert("JavaScript foo value : " + foo);
Sign up to request clarification or add additional context in comments.

3 Comments

Thank's but The problem is that I send to the WebService all the form (I send document.getElementById('FORM').innerHTML;) and there is 180 inputs into. I can't make 180 val()
$("id").find('input[type=text]').each(function(){ //code }); you can get all input text
$("id").find('input[type=text]').each(function(index){ alert("value : " + $(this).val()); }); you can get all input text value ..
0

Try

document.getElementById('foo').outerHTML

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.