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?
<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.