Somewhat closer. var myVar = $(this).attr('name').substr(4); removes data leaving me with ['User']['username'] ['username'] will change from form to form so the replace username will not work because i will maually have to tell it what to strip out for each form field. Image a form that has something like this ['User']['username'] ['User']['email'] ['Post']['title'] ['Post']['description'] ['Comment']['comment'] All i need is User or Post or Comment as a variable. Thanks for your help so far guys. Dave
_____ From: Aivaras [mailto:faifas1...@gmail.com] Sent: September-14-09 11:54 AM To: cake-php@googlegroups.com Subject: Re: Help with variable var myVar = $(this).attr('name').substr(4); myVar = myVar.replace(/\][username]/gi, ''); myVar = myVar.substr(1, myVar.lentgh); Faifas On Mon, Sep 14, 2009 at 15:57, Dave Maharaj :: WidePixels.com <d...@widepixels.com> wrote: I know its more of a jQuery question...i asked on the jQuery group but no luck and its Cake related so I will try here. All the forms have this structure name="data[Model][field]" How can I get User as a variable from name="data[User][username]" var myVar = $(this).attr('name').substr(4); alert(myVar); gets me [User][username] but how can i strip out the rest of the text so i end up with just User Thanks, Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---