QuickForm: Problem enabeling and disabeling Date fields with Javascript
| From: | Mirco Blitz | Date: | Wed, 09 Feb 2005 22:37:54 +0000 |
| Subject: | QuickForm: Problem enabeling and disabeling Date fields with Javascript | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17463@lists.php.net to get a copy of this message | ||
Hi,
I try to write a little javascript that diables a date field set generated
by QuickForm with javascript.
The Date field set has the name "from".
Here is the Javascript:
function setendless()
{
if(document.form.endless.checked==true)
{
document.form.from[d].disabled=true;
document.form.from[m].disabled=true;
document.form.from[Y].disabled=true;
}
else
{
document.form.from[d].disabled=false;
document.form.from[m].disabled=false;
document.form.from[Y].disabled=false;
}
And here the HTML generated by Quickform. (dont bother about html code
around it, that comes from a Template)
<select class="form" name="from[d]">
<option value="1">01</option>
<option value="2">02</option>
.
.
.
<option value="30">30</option>
<option value="31">31</option>
</select><select class="form" name="from[m]">
<option value="1">01</option>
<option value="2" selected="selected">02</option>
.
.
.
<option value="12">12</option>
</select><select class="form" name="from[Y]">
<option value="2005" selected="selected">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
</select>
The Problem is that i cant access the fields by that name.
The Javascript generates an error at document.form.from[d].disabled=true; ,
cause Javascript tries to find an element in the array form[d]. That is
surely not there, cause the elements are no arrays for JavaScript.
Any Ideas how i can solve that problem ?
Thank you very much.
Mirco Blitz