javascript - How to combine the functionality of a list with a textbox -
right have form created in cakephp , works fine problem running run queries off of type in database , there have been user errors spelling have list common types can select if not in list can still type in different.
i found jquery autocomplete combobox works great not able enter not in list. http://jqueryui.com/autocomplete/#combobox
i don't know if need see form or not post anyway
<?php echo $this->form->create( 'credential', array( 'class' => 'popup_form' ) ); echo $this->form->hidden( 'account_id', array( 'value' => $account_id ) ); echo $this->form->hidden( 'user_id', array( 'value' => $currentuser['user']['id'] ) ); echo $this->form->hidden( 'created', array( 'value' => date("y-m-d h:i:s") ) ); echo $this->form->hidden( 'modified', array( 'value' => date("y-m-d h:i:s") ) ); echo '<br/><br/>'; echo $this->form->input( 'type', array( 'div' => false, 'label' => false, 'placeholder' => 'account type' ) ); echo '<br/><br/>'; echo $this->form->input( 'url', array( 'div' => false, 'label' => false, 'placeholder' => 'url' ) ); echo '<br/><br/>'; echo $this->form->input( 'username', array( 'div' => false, 'label' => false, 'placeholder' => 'username' ) ); echo '<br/><br/>'; echo $this->form->input( 'password', array( 'div' => false, 'label' => false, 'placeholder' => 'password' ) ); echo '<br/><br/>'; echo $this->js->submit( 'create credential', array( 'div' => false, 'class' => 'button white medium', 'before' => 'return submitform();', 'success' => "$('#qtip-add_account_credential').hide();", 'complete' => 'loadtasks();' ) ); echo '<br/><br/>'; echo $this->form->end(); ?> <script type="text/javascript"> function submitform(){ var x = document.getelementbyid("credentialtype").value; if (x == null || x == "") { alert("account type must filled out"); return false; } else { return true; } } </script> i backend developer , love on front end. thanks.
what searching datalist (new in html5):
http://www.w3schools.com/tags/tag_datalist.asp
it provides form input predefined list of options, appears user's input matches 1 of entries.
but: seems not supported in safari
in case that:
<input name="type" list="accounttypes" placeholder="account type"> <datalist id="accounttypes"> <option value="admin"> <option value="user"> <option value="something else"> </datalist>
Comments
Post a Comment