case '1':
document.getElementById(q15).options.length = 0;
for (i = 0; i < australia.length; i++) {
createOption(document.getElementById(q15), australia[i], australia[i]);
}
break;
The above code calls the array information:
function createOption(ddl, text, value) {
var opt = document.createElement('option');
opt.value = value;
opt.text = text;
ddl.options.add(opt);
}
The above code creates a drop down as below:
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
etc
What I need is to also get it to add some PHP script as well, is this possible? It would look like this (NOTE: ==1 the '1' needs to be a variable, could it be the '[i] from the top Javascript code?:
<option value="1" <?php if ($results['q14']==1) echo "selected";?>>1</option>
<option value="2" <?php if ($results['q14']==2) echo "selected";?>>2</option>
<option value="3" <?php if ($results['q14']==3) echo "selected";?>>3</option>
json_encode()
'ed values)