Welcome to WebmasterWorld Guest from 54.145.167.92

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

url generator script needed

url generator script needed

   
12:19 pm on Feb 12, 2007 (gmt 0)

5+ Year Member



does anyone know of a link generator for this:

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

9:19 pm on Feb 12, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Welcome to WebmasterWorld, adeibiza!

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!

5:22 pm on Feb 13, 2007 (gmt 0)

5+ Year Member



hmm not really since i want the submit button to actually trigger the url rather than display it - this solution (while very much appreciated:) )would mean 2 clicks rather than one for the user :)
5:29 pm on Feb 13, 2007 (gmt 0)

5+ Year Member



probably an easier way of showing what i'm trying to do:

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">&nbsp;&nbsp;<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 :)

8:49 pm on Feb 13, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Ok, so the solution seems to be JavaScript based, then. Here's what I've come up with real quick:

<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">&nbsp;&nbsp;<input type="Reset">
</form>
</body>
</html>

Hope this helps! :)

7:46 pm on Feb 14, 2007 (gmt 0)

5+ Year Member



brilliant what a star

i had a problem initally with copying and pasting as initially i was getting

option=com_google_maps&amp;category=

which screwed the map up but i went back into the php file and deleted "your &" and typed in an & from keyboard and it works a charm :)

cheers :)