I can't seem to find why this isn't working for me.
I want a conditional statement to change a fileformat based on a checked radio button. I've managed to get it to work for a data type, but not the file extension.
Please can someone tell me why this isn't working?
Thanks
function GetType() {
var type = '';
var fle = '.xml';
var datatype = document.getElementsByName('dtype');
for (var i =0; i < datatype.length; i++) {
if (datatype[i].checked){
type = datatype[i].value;
alert('datatype value is ' + datatype[i].value);
alert('type is ' + type);
if (type = 'csv'){
fle = '.csv';
alert(fle)}
else {
fle = '.xml';
alert(fle);
}
break;
}
}
Each radio button has a value and one of them has "csv". So I want the fileformat to be .xml unless this particular button has been clicked. Then the link is
window.parent.location.href='/tracks/<?php echo $_GET["full_filename"]; ?>' + fle + '?xml_type=' + type;?>'
Thanks in advance
type = 'csv'is an assignment not a comparison. This should betype === 'csv'.