Re: QuickForm: Problem enabeling and disabeling Date fields with Javascript

From: Date: Thu, 10 Feb 2005 05:46:21 +0000
Subject: Re: QuickForm: Problem enabeling and disabeling Date fields with Javascript
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17465@lists.php.net to get a copy of this message
Hello! I think javascript allows only A-Za-z0-9_ in document elements' names just like in variables. Maybe you should give your selects other names? For example, <form name='mircoform' action='...' method='...'> <select name='from_d' > .... </select> <select name='from_m' > .... </select> <select name='from_y' > .... </select> </form> Then your syntax will be correct when you write: document.mircoform.from_d.disabled=false; and so on... Good luck, Valeriy Krizhevich > 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 > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.pear.general (#17465) next »