I'd like set a newly inserted option in a select box as the selected
option. I'm trying to use jQuery to select the option using the option
text, which begins with the author name as defined in the function.

In the examples I've found, $("#refSelectBox option[text^=author]")
would presumably select any option that begins with the literal
"author", but I need it evaluated instead.

Given the following ...

$("#addRefForm").submit(function() {
                        var author = $("#author").val()
                        var detail = $("#detail").val()
                        var refYear = $("#refYear").val()
                        var refType = $("#refType option:selected").val()
                        var newReference = 1
                        $.post('index.cfm?view=saveReferenceFromPopup', {
                                author:author,
                                detail:detail,
                                refYear:refYear,
                                refType:refType,
                                newReference:newReference
                                },  function(data,status) {
                                        if(status == 'success'){
                                                 
$("#refSelectBox").trigger('refreshOpts');
                                                 $("#refSelectBox 
option[text^=author]").attr
("selected","selected");
                                          }
                                  }
                        );

                        $('#dialog').dialog('close');
                        return false;
                });

... how to select the newly inserted option in #refSelectBox using the
text attribute and set it to the selected option?

Any alternate suggestions are most welcome!

Thanks,
Nando

Reply via email to