homepage Welcome to WebmasterWorld Guest from 54.167.185.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
url generator script needed
url generator script needed
adeibiza




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

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

 

eelixduppy




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

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!

adeibiza




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

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 :)

adeibiza




msg:3251524
 5:29 pm on Feb 13, 2007 (gmt 0)

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 :)

eelixduppy




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

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! :)

adeibiza




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

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 :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved