How to perform multiple actions with one form?

随声附和 提交于 2019-12-13 07:59:54

问题


I have a form that takes in a userID. It is located on a page with 3 frames. How would I open two different .jsp's in the frames after the user submits their ID?


回答1:


In your <form/> Tag use the attribute target="_parent" to break up the current frame set. Then in your response you can send a new frameset so that all three frames are reloaded.

Update to clarify it a little bit:

form tag without target attribute: The user submits the form. The server processes the form data and sends a response, i.e. a welcome page. The browser shows this response page in the same frame.

form tag with target="_parent": The user submits the form. Ther server processes the form data and sends a response. The difference here is, that the browser replaces the whole frameset with the server respone. This gives you the chance to update the other frames.

But in this case you have to change the server response. If it is still the welcome page then the browser will show only that page and no other frames. The server response should be a frameset similar to the original frameset. But you can replace the three frame URLs with different URLs:

Original frameset:

<frameset>
  <frame src="login.jsp" name="frame1" />
  <frame src="contentA.jsp" name="frame2" />
  <frame src="contentB.jsp" name="frame3" />
</frameset>

As a response to the user login you send a new frameset

<frameset>
  <frame src="welcome.jsp" name="frame1" />
  <frame src="contentC.jsp" name="frame2" />
  <frame src="contentD.jsp" name="frame3" />
</frameset>


来源:https://stackoverflow.com/questions/7841824/how-to-perform-multiple-actions-with-one-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!