• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

take collection and loop through it, adding attributes together as you go

HTML:

<input name='tbca1' type='text' id='TextBoxCustomAttribs1' gatherkind='createnewuser_requiredfield' customtag='firstname' />
<input name='tbca2' type='text' id='TextBoxCustomAttribs2' gatherkind='createnewuser_requiredfield' customtag='lastname/>
<input name='tbca3' type='text' id='TextBoxCustomAttribs3' gatherkind='createnewuser_requiredfield' customtag='address1' />

What I need is to get a collection of all input tags with gatherkind*='createnewuser_requiredfield' and then loop through the collection building a custom string:

loop....

customstring += customtag + ' : ' + [[value of the input field]] + ', ';



I hope that makes sense.


I'll be working on this as well while I'm waiting.


Thank you!

Tom
0
Tom Knowlton
Asked:
Tom Knowlton
  • 2
2 Solutions
 
leakim971PluritechnicianCommented:
For example : http://jsfiddle.net/Vcs7x/

var customstring = []; // empty new Array
$("input[gatherkind*='createnewuser_requiredfield']").each(function() {
    customstring.push( $(this).val() );
});
customstring = customstring.join(",");

Open in new window

0
 
MacAnthonyCommented:
leakim971 is just missing the custom attribute portion:

var customstring = []; // empty new Array
$("input[gatherkind*='createnewuser_requiredfield']").each(function() {
    customstring.push( $(this).attr('customtag') + ':' + $(this).val() );
});
customstring = customstring.join(",");

Open in new window

0
 
leakim971PluritechnicianCommented:
>leakim971 is just missing the custom attribute portion:

Ooops, my bad!

Check this one : http://jsfiddle.net/Vcs7x/1/


var customstring = {}; // empty new Array
$("input[gatherkind*='createnewuser_requiredfield']").each(function() {
    customstring[$(this).attr("customtag")] = $(this).val();
});

// CHECKING :
alert( JSON.stringify(customstring) );

Open in new window

0
 
Tom KnowltonWeb developerAuthor Commented:
thx!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now