Search code examples
javascriptcsswindows-phone-8textboxibm-mobilefirst

How to show keyboard whenever input the text box


I'm new to Worklight and having many troubles with it.

I'm developing an app using BingMaps. In my app, I use a Search button. When a user wants to search some location, my app show a text box, then user type an address. (When user use this button, must touch the text box one more times to show the keyboard)

But I don't know how to show the keyboard with the text box whenever a user touches the Search button.

This is my code.

<div id="divSearchA" style=" display:none; position:absolute; top:300px; left:90px; right:0px;height:100px; background-color:gray; opacity:0.7;"> 
    <b>Search Box: </b><input id="txtSearchA" style="width:213px" type="text">
    <br>
    <button id="btSearch" onclick="LoadSearchModule()" type="button">Search</button>      
</div> 

Solution

  • A keyboard usually comes to view when the focus is on an input field.

    From your description I understand that in your case the text field is hidden, and in order to display it the end-user taps the "search" button,
    So what I would try to do is: once pressing the search button, that field will get auto-focus thus the keyboard should come to view as well.

    I haven't tried this yet myself so I cannot be certain:

    1. Try adding the autofocus HTML5 attribute to your text field. See if that's suffice
    2. In case 1 above will show a keyboard even when the text field is hidden, try adding it dynamically upon tapping the "search" button.