I hope I explain this well!
I want to pass a form to a server script (to be saved and reloaded
later, but that's besides the point) with all the changes reflected in
passed data.
I have the following:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
$("#save").click(function() {
$("#input").attr("value", "Hella Cool!");
$("#input").attr("align", "bottom");
alert($("form").clone().html());
});
});
</script>
<form>
<input id="input" type="text" value="" />
</form>
<button id="save">Save</button>
When I click on Save I want to see the form HTML in the alert with the
value filled out with whatever I have typed into the input field. I
have tried using val() instead but the same thing happens, I always
get value="" which reflects the original markup!
Notice also that I can change another of the inputs attributes, align
(was the first one that srung to mind :O).
I gave clone a go to. Maybe I have to reconstruct the input and set
the value in that and THEN replace the original.
Any other ideas?
Cheers.
Adrian