Help - Search - Members - Calendar
Full Version: help with http script
MSFN Forums > Coding, Scripting and Servers > Web Development (HTML, Java, PHP, ASP, XML, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
smartie91
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


CODE
<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
Idontwantspam
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.

CODE
<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:
CODE
<br />


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

Thankyou for that info

but what if i need to click on muliple radio buttons then go to a specfic page

thanyou

smartie91
geek
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

CODE
<?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.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.