Possibility of Taking Input from Keyboard or Dropdown menu -
this chunk of code
<div class="form-control"> <div class="input-group"> <span class="input-group-addon"> <input type="text" id = "fromuser"></input> <select id="combobox"> <option value="">select one...</option> <option value="abc">abc</option> <option value="cde">cde</option> <option value="xyz">xyz</option> </select> </span> <button type="submit">submit</button> </div> </div>
what trying achieve user can either type value or select dropdown list. challenge here input keyboard different given in dropdown. example, dropdown has 3 character string options user can type number such 10, 20, 30 etc.
is type of input allowed possible? if so, can me.
the closest come problem dropping select , use autocomplete . full test code follows:-
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jquery ui autocomplete - default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $( function() { var availabletags = [ "abc", "def", "xyz" ]; $( "#tags" ).autocomplete({ source: availabletags }); } ); function myfunction(){ var namevalue = document.forms["formname"]["tags"].value; window.alert(namevalue); } </script> </head> <body> <form name="formname" method="post" /> <div class="ui-widget" > <input name= "tags" id="tags" type="text" onchange="myfunction()"/> <button name="btn-signup" type="submit" value="submit">submit</button> </div> </form> </body> </html>
i know final solution maybe way ahead.
Comments
Post a Comment