Jump to content

help with http script


Recommended Posts

Hi

I wonder if any one can help me i have these checkboxes which i can click a muliple of boxes good so far

but what i need is to go to differant web pages depending which buttons i click on and if i click on tennis reading and boxing it will take me to a page with these sports on

i know they could be a lot of pages .

I hope I have explaned it ok for you

<form id="myform" class="cssform" action="">
<p>
<label for="comments">Hobbies:</label><br>
<input type="checkbox" name="tennis" /> Tennis<br />
<input type="checkbox" name="reading" class="threepxfix" /> Reading <br />
<input type="checkbox" name="basketball" class="threepxfix" /> Basketball <br />
<input type="checkbox" name="boxing" /> Boxing<br />
<input type="checkbox" name="football" class="threepxfix" /> Football<br />
<input type="checkbox" name="cricket" class="threepxfix" /> Cricket <br />
</p>
<div style="margin-left: 150px;">
<input type="submit" value="Submit" onClick="test.html"(this.myform)/>
<input type="reset" value="reset" />
</div>

</form>

</td>
</tr>
</table>

thanks for any help

smartie91

Link to comment
Share on other sites


This won't work with checkboxes, because then what happens if they select multiple boxes, where should it go? What you need to use are radio buttons.

<input type="radio" id="goTo" value="Page 1"/>Page one <br />
<input type="radio" id="goTo" value="Page 2"/>Page two <br />
etc...

Also, if you're using XHTML, make sure to close your line break tags:

<br />

and if you're not using XHTML, don't close your input tags.

Link to comment
Share on other sites

this could prolly be done with a little java script but my JS is too rusty to come up with a maintainable, crossbrowser solution off the top of me head but id try something like this if you have a PHP enabled webserver

<?php
if ($_POST['tennis']=="1" OR $_POST['reading']=="1" OR $_POST['basketball']=="1" OR $_POST['boxing']=="1" OR $_POST['football']=="1" OR $_POST['cricket']=="1") {
if ($_POST['tennis']=="1" AND $_POST['reading']=="1" AND $_POST['boxing']=="1") {
header('Location: http://www.tennisreadingandboxing.com');
}
if ($_POST['tennis']=="1" AND $_POST['reading']=="1") {
header('Location: http://www.tennisandreading.com');
}
} else {
?>
<form id="myform" class="cssform" action="<?php echo $SERVER['PHP_SELF']; ?>" method="POST">
<p>
<label for="comments">Hobbies:</label><br>
<input type="checkbox" value="1" name="tennis" /> Tennis<br />
<input type="checkbox" value="1" name="reading" class="threepxfix" /> Reading <br />
<input type="checkbox" value="1" name="basketball" class="threepxfix" /> Basketball <br />
<input type="checkbox" value="1" name="boxing" /> Boxing<br />
<input type="checkbox" value="1" name="football" class="threepxfix" /> Football<br />
<input type="checkbox" value="1" name="cricket" class="threepxfix" /> Cricket <br />
</p>
<div style="margin-left: 150px;">
<input type="submit" value="Submit">
<input type="reset" value="reset" />
</div>

</form>
<?php
}
?>

Disclaimer: its quick and dirty and there are about a million ways to do it cleaner but its an example. nothing more.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...