Thanks for your answer. Well it looks good but what i'm trying to do is to take the name of the selected input field $('input[name$=the selected input name]').change(function(){
and change the div whoms #id is the same name of the input name. so the second part is ok $('#'+this.name).css('background-color', this.value); thanks Rag On Jan 14, 4:50 pm, Eric Martin <[EMAIL PROTECTED]> wrote: > How about: > > <script type="text/javascript"> > $(document).ready(function () { > $('input[name$=bgcolor]').change(function(){ > $('#'+this.name).css('background-color', this.value); > });}); > > </script> > </head> > > <body> > > <input type="text" name="body_bgcolor" > class="update" value="" class="texte" > style="width:50px;" /> > <input type="text" name="header_bgcolor" > class="update" value="" class="texte" > style="width:50px;" /> > > <div id="body_bgcolor"> > <h1>test</h1> > </div> > > <div id="header_bgcolor"> > <h1>test</h1> > </div> > > </body> > > I wasn't exactly clear on what you were trying to do, but hopefully > the above should help. > > -Eric > > On Jan 14, 3:57 am,hollow<[EMAIL PROTECTED]> wrote: > > > Hi, > > > I'm trying to change color on a div from the change of an input field. > > what i need is to get the name of the input field that is the same as > > the div name ( and the value, to be able to do the change). > > to avoid repeating i'm trying to create one function that can handle > > all. > > the html part: > > > <input type="text" id="body_bgcolor" name="body_bgcolor" > > class="update" value="<?echo $body_bgcolor1 ?>" class="texte" > > style="width:50px;" /> > > <input type="text" id="header_bgcolor" name="header_bgcolor" > > class="update" value="<?echo $header_bgcolor1 ?>" class="texte" > > style="width:50px;" /> > > > $([EMAIL PROTECTED])].change(function(){ > > $(#inputthedivid).css('background-color',' set the new > > color'); > > }); > > > If someone has any ideas on how to do this. > > > Thanks > > Rag