|
-
November 5th, 2009, 03:43 PM
#1
Need help on "onSubmit" Issue
Hi
I have the search functionality with the dropdown values. The UI looks like
Have 8 dropdown values and one test box. When i enter the name in the test box choose the dropdown value . based on that name it should go to that related page. but it always going to the same page (ozPrjFileQuickFind.jsp ) which is File. This is the code i am using for.
Code:
buf.append( "<div id=\"sidebar_quicksearch\" style=\"display: "+showHide+";\"> " );
buf.append( "<table width=100% cellspacing=0 cellpadding=0 border=0 align=center>" );
buf.append( "<tr><td colspan=2 class=normalSmall align=left>"+_p.get("search_bykeyword")+"</td></tr>" );
buf.append( "<tr><td colspan=2 class=verySmall align=left>" );
buf.append( " <form name=QF id=QF action=\"ozPrjFileQuickFind.jsp\" method=post onSubmit=\"Javascript:document.QF.action=document.QF.searchDest.options[document.QF.searchDest.selectedIndex].value;\">" );
buf.append( " <select name=searchDest class=textInputSmall>" );
buf.append( " <option value=\"ozPrjFileQuickFind.jsp\" "+(cat.startsWith("FILE")?"selected":"")+">"+File );
buf.append( " <option value=\"ozPrjBugQuickFind.jsp\" "+(cat.startsWith("BUG")?"selected":"")+">"+Bug );
buf.append( " <option value=\"ozCalApptQuickFind.jsp\" "+(cat.startsWith("APPT")?"selected":"")+">"+Appointment );
buf.append( " <option value=\"ozCalTaskQuickFind.jsp\" "+(cat.startsWith("TASK")?"selected":"")+">"+Task );
buf.append( " <option value=\"ozBbsNoteQuickFind.jsp\" "+(cat.startsWith("NOTE")?"selected":"")+">"+Note);
buf.append( " <option value=\"ozInvPrdQuickFind.jsp\" "+(cat.startsWith("PRODUCT")?"selected":"")+">"+Product );
buf.append( " <option value=\"ozCmnSearchAsset.jsp\" "+( cat.startsWith("ASSET")?"selected":"" )+">"+Asset);
buf.append( " </select><BR>" );
buf.append( " <input class=textInputSmall type=text name=quickFindText value=\"\"></td></tr>" );
buf.append( "<tr><td class=verySmall align=left><input class=\"smallButton\" type=submit name=go value=\""+_p.get("search")+"\">" );
buf.append( "</td><td></form></td></tr>" );
buf.append( "<tr><td colspan=2 height=10><img src=\"graphics/z0.gif\" height=10></td></tr>" );
buf.append( "</table>" );
buf.append( "</div>" );
In the above code File,Bug,Appointment,Task, Note,Product and Asset are the dropdown values. Suppose I enter the test in the test box and choose "Bug" dropdown value it should go to "ozPrjBugQuickFind.jsp" page which is Bug related page. but it always going to the "ozPrjFileQuickFind.jsp" page.
Please respond on this one.
Thanks in advance...
-
November 6th, 2009, 04:32 AM
#2
Re: Need help on "onSubmit" Issue
The direction depends on the action argument of the form.
Code:
buf.append( " <form name=QF id=QF action=\"ozPrjFileQuickFind.jsp\" method=post onSubmit=\"javascript:document.QF.action=document.QF.searchDest.options[document.QF.searchDest.selectedIndex].value;\">" );
I have never seen onSubmit in the the line defining a form. I don't know if this is incorrect, if this is ignored, or if it is superseded by the action. Anyway, I would advise you to remove that onSubmit from that line and use more conservative strategies, e.g. have an onBlur trigger associated to your input field, and that onBlur would call a javascript that will select the appropriate option in the listbox; replace your submit button by an ordinary button so that the submit action of the form will not be called, and associate to that button something like onClick=javascript:location.href=searchDest.options[searchDest.selectedIndex].value.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|