www.webdeveloper.com
Results 1 to 2 of 2

Thread: Need help on "onSubmit" Issue

  1. #1
    Join Date
    May 2008
    Posts
    130

    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...

  2. #2
    Join Date
    Nov 2009
    Posts
    36
    My friend, the submit button does exactly what is defined as the action of the form. In this case you have defined:
    Code:
    ...<form name=QF id=QF action=\"ozPrjFileQuickFind.jsp\" method=post...
    the action is defined "ozPrjFileQuickFind.jsp\". So, when somebody presses the submit button, the action file is called and the selected options are passed as arguments. To do what you want, you should modify the action using js, or use a php script for action, and in that php, get which option is selected and redirect to the proper page.

    Good luck! Ask any question you want my friend.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles