JQuery Grab id's before form submission?

Something along these lines should get you started.

Something along these lines should get you started: $("#sendMail"). Click(function() { var recipients = ""; $("#recipients a"). Each(function() { recpients += this.Id + ","; }); $("#someval(recipients); $("#myForm").

Trigger("submit"); }); You can use each to iterate over the set of a elements, build up a string containing the id values, and use val to set the value of a hidden input element to that string. In the example above you will get a comma-separated string, with a trailing comma. I don't know exactly what you're looking for, so you may want to change that.

This doesn't create a new hidden field and assumes the fields are already in the DOM. – Connell Watkins Nov 10 '11 at 11:20 Yes, that's true. The code in my answer is just meant as a starting point really.

I doubt the OP wants a trailing comma in the hidden input value, but this should be a good starting point. – James Allardice Nov 10 '11 at 11:21 Great, this does what I need it to do! Cheers – Neokoenig Nov 10 '11 at 11:26 I suppose it depends what he's trying to achieve.

Maybe your solution is better for a big series of numbers or small text, instead of filling the DOM with a bunch of small input fields. – Connell Watkins Nov 10 '11 at 11:29.

You could use the append function to create the new hidden fields. So to loop round all a tags in recipients and append a new hidden field: $("#recipients a"). Each(function() { $("#myform").

Append('') }); Note: you didn't say what you want the name and value of the hidden fields to be, so I guessed at using this. Id for the name and $(this).text() for the value.

Try this var Anchors = $("body"). Find("a") var str = ""; alert(Anchors. Length); $(Anchors).

Each(function(){ if(str! == ""){ str+=","; } str+=$(this). Attr("id"); }) $("sometextfieldid").

Val(str).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions