javascript - Get value from text field and show in select field -


hi have cna me want vlaue text field , show in select javascript or jquery.

        <ul class="title_customer">             <li>         <label for="offaddress" class="title_register"><!--<em>*</em>--><?php echo $this->__('title') ?></label>         <div class="input-box">            <div type="text" name="offaddress1" id="offaddress1" value="<?php echo $this->htmlescape($this->getcustomer()->getoffaddress()) ?>" title="<?php echo $this->__('office address') ?>" class="input-text " >             <input type="text" name="offaddress1" id="offaddress1" value="<?php echo $this->htmlescape($this->getcustomer()->getoffaddress()) ?>" title="<?php echo $this->__('office address') ?>" class="input-text" />            </div>         </div>      </li>         <li>         <label for="offaddress" class="title_register"><!--<em>*</em>--><?php echo $this->__('choose title') ?></label>         <div class="input-box">            <select type="text" name="offaddress" id="offaddress" value="<?php echo $this->htmlescape($this->getcustomer()->getoffaddress()) ?>" title="<?php echo $this->__('office address') ?>" class="input-text " >                <option value="dep">dep</option>                <option value="dr">dr</option>                <option value="miss">miss</option>                <option value="mr">mr</option>                <option value="mrs">mrs</option>                <option value="ms">ms</option>                <option value="sir">sir</option>                <option value="ls">ls</option>            </select>         </div>     </li>     </ul> 

you can run loop on options inside of blur function if user inputs e.g

var b; $('#offaddress1').on('blur',function(){   var = $(this).val();           $('#offaddress option').each(function(){     b = $(this).val();     $(this).val(b + ' ' + a).html(b + ' ' + a);   }); }); 

or can read current value if filled on page load doing like

var b; var = $('#offaddress1').val();         $('#offaddress option').each(function(){   b = $(this).val();   $(this).val(b + ' ' + a).html(b + ' ' + a); }); 

you could/should tidy variable names , tweak runs on page load , on blur.

the problem using same id input , wrapping div unless change wont work.

i've not tested these @ great length didn't add attempts


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -