Doc Holiday
Doc Holiday

Reputation: 10254

Javascript--Object Expected

Hello guys Im trying to change a select box based on a Text box next to it and I get object expected?

JSP:

NSN:&nbsp;<input type="text" name="nsn" value=""/>
TAMCN:&nbsp;<input type="text" id="tamcn" name="tamcn" value=""  size="6" maxlength="5" onkeyup="javascript:tamcnSearchUpdated(this.value,'detSearchForm')" onkeypress="javascript:return noenter();" autocomplete="off" />


<select id="tamcnList" name="tamcnList" onchange="javascript:this.form.tamcn.value = '';">
    <option value=""<c:if test="${empty form.tamcnList}"> selected="selected"</c:if>>&nbsp;</option>
    <c:forEach var="tamcn" items="${tamcns}"><option value="${tamcn.code}"<c:if test="${tamcn.code == form.tamcnList}"> selected="selected"</c:if>>${tamcn.code}</option></c:forEach>

JAVASCRIPT:

function tamcnSearchUpdated(tamcn, formName){
    var tamcnUpper = tamcn.toUpperCase();
    document.forms[formName].elements.tamcn.value = tamcnUpper;

    var len = tamcn.length;
    if ( tamcnUpper.indexOf('*') >= 0 )
    {
        document.forms[formName].elements['tamcnList'].options[0].selected = 'selected';
        return;
    }

    for (var i = 0; i < document.forms[formName].elements['tamcnList'].options.length; i++)
    {
        if (document.forms[formName].elements['tamcnList'].options[i].text.substr(0,len) == tamcnUpper)
        {
            document.forms[formName].elements['tamcnList'].options[i].selected = 'selected';
            return;
        }
    }

    document.forms[formName].elements['tamcnList'].options[0].selected = 'selected';
}

I get object expected here:

onkeyup="javascript:tamcnSearchUpdated(this.value,'detSearchForm')"

this page is called filters.jsp and is an include on a master page where the form is set:

<form action="process.det_details" method="get" name="detSearchForm">       
<table class="data_table" width="100%">

<!--<jsp:include page="../../jsp/det/data_extract_favorites.jsp" flush="false"/> -->

<jsp:include page="../../jsp/det/data_extract_fields.jsp" flush="false"/>

<jsp:include page="../../jsp/det/data_extract_size.jsp" flush="false"/>

<jsp:include page="../../jsp/det/data_extract_filters.jsp" flush="false"/>

<jsp:include page="../../jsp/det/data_extract_results.jsp" flush="false"/>

</table>
</form>

Upvotes: 0

Views: 959

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324610

onkeyup (and other inline events) do NOT need javascript: in front of them. That is ONLY needed for href attributes on links (or action on forms). Remove that and you're good.

Upvotes: 1

Related Questions