开发者

How can I use jQuery to show and hide DIVs based on checkboxes in a submitted form from a different page?

I need to submit a form on one page, and show and hide DIVs on the receiving page based on 开发者_运维百科what checkboxes were checked. The script also needs to display different messages for no checkboxes being checked, some checkboxes being checked, or all checkboxes being checked. Both pages are static HTML.


The form would need to use the GET action so it passes the values on the querystring. Then from Javascript, you need to look at the QueryString to evaluate what was checked. Details of doing than are explained in this question on SO:

get querystring with jQuery


If you were displaying both pages within a single page by using frames or iframes, then you could traverse the DOM to get to whatever elements you wanted to in order to change what's being rendered (I think). In this case, both pages would need to be on the same server (or some domain anyway) to avoid being blocked for cross-site scripting.

Another option would be to embed both "pages" in the same HTML document, have one in a hidden div, which you then show when the user clicks submit.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜