jQuery $(“#field”) is null?

I have a selectbox with month periods in it.

Here is my code:

                                        var term = this.options[this.selectedIndex].text; 
                                        if(term == "Eenmalig"){ 
                                                //$("#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> 

But when i load my page i staight away get an error:

$(“#ppsub_ppterm_id”) is null

Line 17

Any ideas?

UIPickerView – 1st row selection does not call didSelectRow

I have a UIPickerView on my UIView along with a UITextField. I am letting the user select a value from the picker or enter a custom value in the text field.

When the user selects any option from the picker, the variable values are changed fine (in the pickerView:didSelectRow:inComponent:) method. But if the user does not select any value on the picker (coz they want to select the 1st option which is already selected), this method is not called and the selection is not reflected in the variable.

I tried setting the default value of the variable to the first option in the picker. But in that case, when the user edits the text field, the variable will have the text field’s text. Now if the user decides to pick the first value again, the new value is not reflected in the variable.

How can I overcome this? Thanks.

Here’s the relevant code

In my viewDidLoad I have this statement to set the selectText to first option of the picker by default

[self setSelectText:[myArray objectAtIndex:0]];


- (BOOL)textFieldShouldReturn:(UITextField *)txtField{
    [txtField resignFirstResponder];
    [self setSelectText:txtField.text];
    return YES;

PickerViewDelegate’s didSelectRow

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
    // report the selection to the UI label
    [self setSelectText:[myArray objectAtIndex:[pickerView selectedRowInComponent:0]]];

The problem arises when the user edits the text and then decides he after all wants to use the first value of the picker. In that case they will dismiss the keyboard and click on the 1st option of the picker (which is already selected). This action does not call didSelectRow and so the value of selectText is not changed.

In order for the user to be able to change the value of selectText, they first have to select some other value from the picker and then select the 1st row.