Dak Posted May 21, 2006 Posted May 21, 2006 i need a form that someone can fill out, and which will then redirect them to another page which displays stuff (or not) dependant on the way that they filled out the form. I also need the form to save its data using GET, so that the URL can be copied and passed to someone else, who can then view the page. In other words, i need a form that will allow someone to 'customise' a webpage for someone else. now... i can't play about with any server-side gubbins; the only way i can conditionally display stuff is using javascript. which i dont know i've got as far as figuring out stuff like <script type="text/javascript"> if (variable1 == yes) ( document.write ("you chose variable one") ) </script> but the thing that i can't figure out is how to grab the GET data that is stored in the URL using javascript? I've googled about for ages, and can't find it anywhere. if anyone knows how to do this, i'd greatly appreciate it if they would tell me
Cap'n Refsmmat Posted May 21, 2006 Posted May 21, 2006 I have a feeling you'd have to use some substring methods to extract it out of document.location.
Dak Posted May 21, 2006 Author Posted May 21, 2006 there's no easy way to do it? poop. still... i've just discovered the 'split' thing, and i'm having fun i've allready managed to get one of the GET thingies. <h3>Hello<script type="text/javascript"> var url = window.location.href var url2 = url.split("?") var username = url2[1] var username2 = username.split("=") if (username2[0] == "username") { var username3 = username2[1] var username4 = username3.split("&") document.write (" " username4[0]) } </script>, and welcome...</h3> (i know the last document.write bit's wrong btw) whilst kinda fun, this strikes me as the long way of doing this, and i think the fun's going to evaporate as soon as i get onto the rest of the GET data
RyanJ Posted May 21, 2006 Posted May 21, 2006 Yes, that's the only way to do it. You could always wrap it in a function though and let that do all the dirty work for you Cheers, Ryan Jones
Dak Posted May 21, 2006 Author Posted May 21, 2006 man, i finally did it. that was such a pain in the arse. cheers both.
5614 Posted May 24, 2006 Posted May 24, 2006 What did the final code look like? (just outta interest)
Dak Posted May 25, 2006 Author Posted May 25, 2006 it's on this page There's another page that generates the url. (theyre just demos of an idea atm) it wasn't actually that hard in the end, just very confusing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now