Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 25th, 2005, 09:25 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Forms and drop down boxes

Hi,
   I want to know how to make an age option box which when an age is selected if its below 25 then it disables another tick box say if you have children. heres the code i am using, could anyone try and intergrate it within

<form action=/cgi-bin/guest method=post name=fhguest>
<table border=0 cellpadding=2 cellspacing=0>
<tr><td align=right>Name:</td><td><input type=text size=40 name=guest_name value='' maxlength=50></td></tr>
<tr><td align=right>Email:</td><td><input type=text size=40 name=guest_email value='' maxlength=100></td></tr>
<tr><td align=right>Where are<br>you from:</td><td><input type=text size=40 name=guest_address value='' maxlength=100></td></tr>
<tr><td valign=top align=right>Comments:</td><td><textarea name=guest_comments rows=4 cols=40 wrap=virtual></textarea></td></tr>

<tr>
<td align=right>How old are you:</td>
<td>
<select name=guest_opt1>
<option value=">25">> 25</option>
<option value="<25">< 25</option>
</select>
</td>
</tr>

<tr><td align=right>Is Your Child At Hanley:</td><td><input type=text size=40 name=guest_opt2 value='' maxlength=100></td></tr>
<tr><td>&nbsp;</td><td><input type=submit value='Submit My Information'><input type=reset value=Clear><input type='button' value='Home Page' onClick=location.href='http://callumsschool.9k.com'></td></tr>
</table></form><br />

__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old December 6th, 2005, 11:26 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Apocalypse,

I think this is something like what you are looking for:


<form name ="form1">
<select name = "guest_opt1" onchange ="compare(document.form1.guest_opt1.selectedIndex) ">
<option value = 0>>25
<option value = 1><25
</option>
</select>

Do you have children?
<input type = "checkbox" name ="childCheck">
</form>
<script language ="javascript">
function compare(checkAge){

        if (checkAge ==1){
            document.form1.childCheck.disabled = true
            }

                if(checkAge ==0){
                document.form1.childCheck.disabled = false
                }

                        if (document.form1.childCheck.disabled ==true){
                        document.form1.childCheck.checked =false
                        }
}
</script>

Cheers
Joe






Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down boxes in Cells and selecting ranges tbmbob Excel VBA 0 June 1st, 2006 09:12 AM
Compare values of several drop boxes, notify user SoC Javascript How-To 1 April 21st, 2005 10:17 AM
drag and drop to multiple text boxes gbuller VB.NET 5 September 6th, 2004 09:55 PM
Assigning Macros to Drop Down Boxes ashu_gupta75 Excel VBA 1 August 12th, 2004 12:44 AM
Two drop down dependent list boxes and a Button tcasp Classic ASP Basics 0 August 5th, 2003 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.