SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,338
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Updating JS to work with iPhone: populating a text field from a drop-down

    I found the following code to populate a text field based on a selection. But it is not working on the iPhone device. I'm using PhoneGap, building my pages with HTML, CSS, JS. What needs to change to make this compatible?

    Code:
    <script type="text/Javascript">
    window.onload=function() {
    if (document.getElementById) {
    document.getElementById("SOneSurface").onchange=function() { switchme(this); }
    }
    }
    function switchme(SNewSel) {
    var ind = SNewSel.selectedIndex;
    var txt = document.getElementById('SOneSurfaceLoad');
    switch (ind) {
    case 1:
    txt.value = "Flat";
    break;
    case 2:
    txt.value = "Somewhat Flat";  
    break;   
    case 3:
    txt.value = "Bumpy";  
    break; 
    case 4:
    txt.value = "Very Bumpy";  
    break; 
    case 5:
    txt.value = "see notes";  
    break;  
    }
    }
    </script>    
                
                <!-- Start of first page -->
                <div data-role="page" id="SOnetrackCond" data-theme="b" data-add-back-btn="true">               
                    <div data-role="header">
                        <h1>Setup 1</h1>
                    </div><!-- /header -->
                    
                    
                    <div data-role="content"><form name="form1c">
                                        <ul data-role="listview" data-dividertheme="b">
                            
                            <li data-role="list-divider">Track Conditions</li>
                            
                            <li>Surface<br>
                                
                                <select size="1" name="SOneSurface" id="SOneSurface">
                                    <option value="">Surface</option>
                                    <option value="Flat">Flat smooth</option>
                                    <option value="Somewhat Flat">Somewhat Flat</option>
                                    <option value="Bumpy">Bumpy</option>
                                    <option value="Very Bumpy">Very Bumpy</option>
                                    <option value="see notes">see notes</option>
                                </select>
                            <input type="text" name="SOneSurfaceLoad" placeholder="Do not type here" class="loadField" data-role="none"></li>
    Quite possibly it is the wrong code anyway. I want the text field to populate immediately upon the selection being made.

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,338
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I found an answer. This is solved.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •