Forum Moderators: coopster
i'm using google maps on joomla and am creating a number of maps - what i would like to do on one main page is have a set of checkboxs/radio buttons so that the user can pick say "towns" & beaches and it would generate the corresponding link on a form button
the variables are all numerical
eg towns is 1
beaches is 2 etc
the result would be
/index.php?option=com_google_maps&category=1,2
im sure this is far easier than i think but i cant get my head around it
Does the data have to be GET? If not, then POST would be much better in this instance. By naming the checkbox for category something like this:
<input type="checkbox" name="[b]cat[][/b]" value="....
for each checkbox, you can then get the information as an array on the action page. This can be seen by adding this to the action page, which, in this case, is index.php:
echo '<pre>'; print_r($_POST['cat']); echo '</pre>'; #prints the array
Let me know if this isn't a possibility as there may be other solutions :)
Good luck!
basic idea:
<form method=etcetc>
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td><input type="checkbox" name="beaches" value="1"></td>
<td>Beaches</td>
<td><input type="checkbox" name="towns" value="2"></td>
<td>Towns & Villages</td>
</tr>
<tr>
<td><input type="checkbox" name="clubs" value="3"></td>
<td>Clubs</td>
<td><input type="checkbox" name="bbars" value="4"></td>
<td>Beach Bars</td>
</tr>
</table><input type="submit" value="click for combined map"> <input type="Reset">
</form>
which would add 1,2 or 2,3,4 or 2,4 etc to the end of the url depending on which checkboxes were ticked :)
<html>
<head>
[b]
<script type="text/javascript">
function go_to_page()
{
var form = document.form;
var values = new Array();
for(var i=0; i < (form.elements.length - 2); i++) { //the minus 2 here is to account for the buttons (submit and reset)
if(form.elements[i].checked) { //check to see if they are checked
values.push(form.elements[i].value); //if checked, push onto array
}
}
var cat = values.join(","); //join the array elements with a comma
document.location.href = "/index.php?option=com_google_maps&category="+cat;
}
</script>
[/b]
</head>
<body>
<form name="form">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td><input type="checkbox" name="beaches" value="1"></td>
<td>Beaches</td>
<td><input type="checkbox" name="towns" value="2"></td>
<td>Towns & Villages</td>
</tr>
<tr>
<td><input type="checkbox" name="clubs" value="3"></td>
<td>Clubs</td>
<td><input type="checkbox" name="bbars" value="4"></td>
<td>Beach Bars</td>
</tr>
</table><input [b]type="button" onClick="go_to_page();"[/b] value="click for combined map"> <input type="Reset">
</form>
</body>
</html>
Hope this helps! :)