JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 10th, 2004, 07:54 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 236 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 50 m 36 sec
Reputation Power: 7
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Enablling and disabling <select>

I had code which could enable and disbale text inputs (<input type=text>). Figuring it would work on <select> as well, I modified it to work with the form I am working on. However, when I click the checkbox it does not enable the three select boxes I need enabled. Below is my code for the script and the form

PHP Code:
<?php
$categorydb
=getDbCategory($level);
$categoryname=getCategoryName($level);
?>
<script language="JavaScript" type="text/javascript">
<!--
function multiday()
{
if(document.addcalform.multiday.checked)
{
document.addcalform.end_month.disabled=false;
document.addcalform.end_date.disabled=false;
document.addcalform.end_year.disabled=false;
}
else
{
document.addcalform.end_month.disabled=true;
document.addcalform.end_date.disabled=true;
document.addcalform.end_year.disabled=true;
}
}
//-->
</script>

<form name="addcalform" method="post" action="addcal.php">
<div>
Event Name:<span style="font-size: small">(30 character maximum)</span><br />
<input type="text" name="event" maxlength="30" size="30" value="<?php echo $event?>" style="background-color: #f8f8ff;" tabindex="1" /><br />
Event Category:<br />
<select name="category">
<?php
if($case==1)
{
?>
<option selected value="<?php echo $category?>"><?php $newstype ?> Event</option>
<?php
}/* Closes line # - if($case==1) */
else/* If on line # */
{
?>
<option selected value="">Please Choose an Event Category</option>
<?php
}/* Closes lin # - else - if($case==1) */
for(;list(,$dbcategory)=each($categorydb),list(,$n  amecategory)=each($categoryname);)
{
?>
<option value="<?php echo $dbcategory?>"><?php echo $namecategory?></option>
<?php
}/* Closes line # - for(;list(,$dbcategory)=each($categorydb),list(,$n  amecategory)=each($categoryname)) */
?>
</select><!-- Closes 'select name="category"' on line # --><br />
Event Start Date:&nbsp;
<select name="start_month">
<?php
if($case==1)
{
?>
<option selected value="<?php echo $start_month?>"><?php $start_month_name=optionmonthname($start_month); echo $start_month_name?></option>
<?php
}/* Closes line # - if($case==1) */
else/* if() on line # */
{
?>
<option selected value="">Month</option>
<?php
}/* Closes line # - else - if($case==1) */
?>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select><!-- Closes 'select name="start_month"' on line # -->
<select name="start_date">
<?php
if($case==1)
{
?>
<option selected value="<?php echo $start_date?>"><?php echo $start_date?></option>
<?php
}/* Closes line # - if($case==1) */
else/* if() on line # */
{
?>
<option selected value="0">Date</option>
<?php
}/* Closes line # - else - if($case==1) */
$date_option=1;
while(
$date_option<=31)
{
?>
<option value="<?php echo $date_option?>"><?php echo $date_option?></option>
<?php
$date_option
++;
}
/* Closes line # - while($date_option<=31) */
?>
</select><!-- Closes 'select name="start_date"' on line # -->
<select name="start_year">
<?php
if($case==1)
{
?>
<option selected value="<?php echo $start_year?>"><?php echo $start_year?></option>
<?php
}/* Closes line # - if($case==1) */
else/* if() on line # */
{
?>
<option selected value="">Year</option>
<?php
}/* Closes line # - else - if($case==1) */
$today=getdate();
$year=$today['year'];
$loopyear=1;
while(
$loopyear<=4)
{
?>
<option value="<?php echo $year?>"><?php echo $year?></option>
<?php
$year
++;
$loopyear++;
}
/* Closes line # - while($loopyear<=4) */
?>
</select><!-- Close 'selecet name="start_year"' on line # --><br />
Is this a multiday day event?<input type="checkbox" name="multiday" value="1" onclick="multiday()"><br />
Event End Date (if a multiday Event):&nbsp;
<select disabled name="end_month">
<?php
if($case==&& $multiday==1)
{
?>
<option selected value="<?php echo $end_month?>"><?php $month_name=optionmonthname($end_month); echo $month_name?></option>
<?php
}/* Closes line # - if($case==1) */
else/* if() on line # */
{
?>
<option selected value="00">Month</option>
<?php
}/* Closes line # - else - if($case==1) */
?>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select><!-- Closes 'select name="end_month"' on line # -->
<select disabled name="end_date">
<?php
if($case==&& multiday==1)
{
?>
<option selected value="<?php echo $end_date?>"><?php echo $end_date?></option>
<?php
}/* Closes line # - if($case==1) */
else/* if() on line # */
{
?>
<option selected value="0">Date</option>
<?php
}/* Closes line # - else - if($case==1) */
$date_option=1;
while(
$date_option<=31)
{
?>
<option value="<?php echo $date_option?>"><?php echo $date_option?></option>
<?php
$date_option
++;
}
/* Closes line # - while($date_option<=31) */
?>
</select><!-- Closes 'select name="end_date"' on line # -->
<select disabled name="end_year">
<?php
if($case==&& multiday==1)
{
?>
<option selected value="<?php echo $end_year?>"><?php echo $end_year?></option>
<?php
}/* Closes line # - if($case==1) */
else/* if() on line # */
{
?>
<option selected value="00">Year</option>
<?php
}/* Closes line # - else - if($case==1) */
$today=getdate();
$year=$today['year'];
$loopyear=1;
while(
$loopyear<=4)
{
?>
<option value="<?php echo $year?>"><?php echo $year?></option>
<?php
$year
++;
$loopyear++;
}
/* Closes line # - while($loopyear<=4) */
?>
</select><!-- Close 'selecet name="end_year"' on line # --><br />

</div><!-- Closes 'div' on line # -->
</form><!-- Closes 'form name="addcalform"' on line # -->
__________________
CHornJr
"One day I'll know what I am doing"
My Blog
Suanhacky Lodge #49
Rebel Squadrons

Reply With Quote
  #2  
Old January 11th, 2004, 08:22 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Can you just post the final rendered HTML, for those that don't use PHP?

Reply With Quote
  #3  
Old January 11th, 2004, 11:27 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 236 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 50 m 36 sec
Reputation Power: 7
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Sorry about that, force of habit

PHP Code:
<script language="JavaScript" type="text/javascript">
<!--
function 
multiday()
{
if(
document.addcalform.multiday.checked)
{
document.addcalform.end_month.disabled=false;
document.addcalform.end_date.disabled=false;
document.addcalform.end_year.disabled=false;
}
else
{
document.addcalform.end_month.disabled=true;
document.addcalform.end_date.disabled=true;
document.addcalform.end_year.disabled=true;
}
}
//-->
</script>
<form name="addcalform" method="post" action="addcal.php">
<div>
Event Name:<span style="font-size: small">(30 character maximum)</span><br />
<input type="text" name="event" maxlength="30" size="30" value="" style="background-color: #f8f8ff;" tabindex="1" /><br />
Event Category:<br />
<select name="category">
<option selected value="">Please Choose an Event Category</option>
<option value="1">Lodge</option>
<option value="2">Suanhacky.org</option>
<option value="3">Catawba</option>
<option value="4">Matinecock</option>
<option value="5">Wandowenock</option>
<option value="6">National, Regional or Section</option>
</select><!-- Closes 'select name="category"' on line # --><br />
Event Start Date:&nbsp;
<select name="start_month">
<option selected value="">Month</option>
<option value="01">January</option>
<!-- All the months in between -->
<option value="12">December</option>
</select><!-- Closes 'select name="start_month"' on line # -->
<select name="start_date">
<option selected value="0">Date</option>
<option value="1">1</option>
<!-- All the numbers in between -->
<option value="31">31</option>
</select><!-- Closes 'select name="start_date"' on line # -->
<select name="start_year">
<option selected value="">Year</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
</select><!-- Close 'selecet name="start_year"' on line # --><br />
Is this a multiday day event?<input type="checkbox" name="multiday" value="1" onclick="multiday()"><br />
Event End Date (if a multiday Event):&nbsp;
<select disabled name="end_month">
<option selected value="00">Month</option>
<option value="01">January</option>
<!-- All the months in between -->
<option value="12">December</option>
</select><!-- Closes 'select name="end_month"' on line # -->
<select disabled name="end_date">
<option selected value="0">Date</option>
<option value="1">1</option>
<!-- All the months in between -->
<option value="31">31</option>
</select><!-- Closes 'select name="end_date"' on line # -->
<select disabled name="end_year">
<option selected value="00">Year</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
</select><!-- Close 'selecet name="end_year"' on line # --><br />
</div><!-- Closes 'div' on line # -->
</form><!-- Closes 'form name="addcalform"' on line # 

Reply With Quote
  #4  
Old January 11th, 2004, 11:46 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Just change the name of your checkbox to something like chkMultiday (don't forget to change it in the JS too).

The reason why - the JS engine is getting confused with your naming - you shouldn't use the same names for anything. You have used "multiday" for both a function, and the checkobx.

Reply With Quote
  #5  
Old January 12th, 2004, 04:25 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 236 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 50 m 36 sec
Reputation Power: 7
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Thank You for pointing that out. I will (hopefully) never make that same stupid error again.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Enablling and disabling <select>


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT