0

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>
3
  • How are you rendering the detSearchForm form to the page? Commented Feb 9, 2012 at 17:51
  • 1
    I don't think you need the javascript: bit when defining the onkeyup handler. Commented Feb 9, 2012 at 17:56
  • @pete I just updated the question Commented Feb 9, 2012 at 19:17

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

that didnt work...Im doing this in other places and it seems to work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.