has nothing to do with the .text method, as he is saying his selector
isn't working (hence the "null" message)... besides that is perfectly
valid JavaScript to get the text value from an <option>
jjsanders:
What happens if before this line
$(function(){
you put
alert($);
because the fact you get "null" on $("#ppsub_ppterm_id") and not have
jQuery go about it's business silently (which it should), means you
don't have jQuery referenced properly or it's conflicting with
something else used on the page
On Apr 22, 9:03 am, Abrar Arshad <[email protected]> wrote:
> hi,
> i didnt try it but i think the problem is with your text() method that
> you have used as a property on 3rd line.
>
> On Wed, Apr 22, 2009 at 3:48 PM, jjsanders <[email protected]> wrote:
>
> > Hello,
>
> > I have a selectbox with month periods in it.
>
> > Here is my code:
>
> > $(function(){
>
> > $("#ppsub_ppterm_id").change(function(){
> > var term =
> > this.options[this.selectedIndex].text;
>
> > if(term == "Eenmalig"){
> > $(".idealtd").show();
> > }else{
> > $(".idealtd").hide();
> > //$("#ppsub_amount
> > option:selected").val('anders');
> > }
> > });
>
> > });
>
> > <select name="ppsub_ppterm_id" class="ppsub_ppterm_id"
> > id="ppsub_ppterm_id" style="width: 100px; font-size: 11px;">
> > <option
> > value="M">Maand</option>
> > <option
> > value="K">Kwartaal</option>
> > <option
> > value="H">Halfjaar</option>
> > <option
> > value="J">Jaar</option>
> > <option selected
> > value="E">Eenmalig</option>
> > </select>
>
> > But when i load my page i staight away get an error:
>
> > $("#ppsub_ppterm_id") is null
> > Line 17
>
> > any idea's?