Modify the value of the hidden input part of the parent page on the iframe page. The change event cannot be triggered ., Iframeparent

Source: Internet
Author: User

Modify the value of the hidden input part of the parent page on the iframe page. The change event cannot be triggered ., Iframeparent

Different input components are arranged according to the type of the recharge card returned by the iframe page.

Click "select" to bring up an iframe, click the recharge card data line, and return 1. Recharge card type. 2. Recharge card id (UUID used ). 3. Recharge card number (string ).

The problem is that when iframe is set to a recharge card, the change event of the value of the input part on the parent page cannot be obtained.

Parent page js

$ ("# Id_card_type"). change (function () {// events cannot be captured });
Parent page form

<Form id = "frm" method = "post" action = "/bill/recharge/new/"> <input id = "id_card_type" name = "card_type" type = "hidden "/> <input id =" id_card_id "name =" card_id "type =" hidden "/> <label> card number </label> <input id =" id_cardno "name =" cardno "readonly =" True "type =" text "/> <span id =" btnSelectCard "> select </span> </form>

Iframe page js

$(this).children().click(function(){<span style="white-space:pre"></span>var cid=$(this).parent('tr').attr('item_id');var cn=$(this).parent('tr').children('td').eq(0).html();var ct=$(this).parent('tr').attr('item_type');$('#id_card_id', window.parent.document).val(cid);$('#id_cardno', window.parent.document).val(cn);$('#id_card_type', window.parent.document).val(ct);});


The solution is as follows:


Iframe page js

$ (This ). children (). click (function () {var cid = $ (this ). parent ('tr '). attr ('item _ id'); var cn1_0000(this%.parent('tr'%.children('td'%.eq(0%.html (); var ct = $ (this ). parent ('tr '). attr ('item _ type'); $ ('# id_card_id', specify parameter parent.doc ument ). val (cid); $ ('# id_cardno', specify parameter parent.doc ument ). val (cn); $ ('# id_card_type', specify parameter parent.doc ument ). val (ct); // $ ('# id_card_type', optional parameter parent.doc ument ). trigger ('change'); // The window is invalid. parent. $ ('# id_card_type '). trigger ('change'); // valid });



How does iframe obtain a variable value of the parent page and give this value to the input value?

Certificate (registry.parent.doc ument. body). find ("you are looking ")...

Iframe code question: can I hide the upper part of the called page by changing an attribute value?

Make the page to be nested into a frame, and hide the upper half of the frame.

No code is written.

Wish you success

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.