You're nearly there, but what you need to do is *append* to the
#updstr field, whereas you are currently overwriting its value with
each iteration of each!
Personally, I would probably do it slightly differently, eg...

$(document).ready(function(){
    var upd = [];
    $( 'input[name^=rlinehval-]' ).each(function(){
        upd.push( $(this).val();
      });
    $("#updstr").val( upd.join(';') );
});


On Dec 17, 11:35 pm, JimD <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Pretty basic but Im having some difficulty. When my form is submitted,
> I want to capture all the form element textfield values where the name
> begins with 'rlinehval-' and put them into a hidden field value with
> the id "updstr" as a semicolon delimited list for a db update. I read
> through the selector docs but this doesnt seem to work.
>
> Using Jquery I am trying this:
> $(document).ready(function(){
>     $('[EMAIL PROTECTED]').each(function(){
>     var sv = this.value + ";";
>     $("#updstr").val(sv);
>   });
>
> });
>
> So in the case of the example form below, when submitted I collect all
> the values for the fields where the name starts with ''rlinehval-" and
> put them in a hidden field value as a semicolon delimited string
>
> On submission the hidden field named "updstr" would be:
> 0056543,DVD;0024543,BLU
>
> Simple demo form
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <script type="text/javascript" src="jquery-latest.js"></script>
> <script type="text/javascript">
> $(document).ready(function(){
>     $('[EMAIL PROTECTED]').each(function(){
>     var sv = this.value + ";";
>     $("#updstr").val(sv);
>   });});
>
> </script>
> </head>
> <body>
> <form id="myform" class="cssform" action="">
>   <input type="hidden" id="updstr" name="updstr" value="">
>   <p>
>     <label for="user">Item1</label>
>     <input name="rlinehval-1" type="text" id="rlinehval-1"
> value="0056543,DVD" />
>   </p>
>   <p>
>     <label for="user">Item2</label>
>     <input name="rlinehval-2" type="text" id="rlinehval-2"
> value="0024543,BLU" />
>   </p>
>   <input type="submit" value="Submit" />
>   <input type="reset" value="reset" />
> </form>
> </body>
> </html>

Reply via email to