I can't quite get this figured out and maybe I am going about it the wrong way?? (more than likely!) Here is what I would like to do: I have a php webpage with 2 radio buttons and when someone changes the value a couple labels will change and then set a variable. I have the code written so that when the page loads, it will check the correct value based on the value stored. My thought was that in the onchange() function I will just need to get the radio button that is checked and store the variable and refresh the page? If that isn't the best method, I am open for suggestions. Here is what I have:
<script>
function displayRadioValue() {
var ele = document.getElementsByName('country');
for(i = 0; i < ele.length; i++) {
if(ele[i].checked)
<? $COUNTRY="US"; ?>
}
}
</script>
<?php
$COUNTRY = urldecode($pluginSettings['COUNTRY']);
?>
Select your country
<input type="radio" id="us" name="country" value="US" onclick="displayRadioValue()" <? if ($COUNTRY=="US") echo "checked"; ?>>
<label for="us">US</label>
<input type="radio" id="other" name="country" value="Other" onclick="displayRadioValue()"<? if ($COUNTRY=="Other") echo "checked"; ?>>
<label for="other">Other</label><p/>
<? if ($COUNTRY=="US"){
echo "City:";
} else {
echo "Latitude";
}
?>
<input type="text" name="CITY" size="16" value="<? echo $CITY; ?>"> <p>
<? if ($COUNTRY=="US"){
echo "State:";
} else {
echo "Longitude";
}
?>
<input type="text" name="STATE" size="12" value="<? echo $STATE; ?>"> <p>
What am I doing wrong?