javascript - pass selected value from popup window to parent window input box

前端 未结 5 985
逝去的感伤
逝去的感伤 2020-11-29 23:20

I am building an order form with PHP and MySQL.

The PHP Form has an input box where the user types in a product code. In the event that the user does not know the pr

5条回答
  •  庸人自扰
    2020-11-30 00:08

    From your code

    Im not sure that your this.form.details valid or not.

    IF it's valid, have a look in window.opener.document.getElementById('details').value = selvalue;

    I can't found an input's id contain details I'm just found only id=sku1 (recommend you to add " like id="sku1").

    And from your id it's hardcode. Let's see how to do with dynamic when a child has callback to update some textbox on the parent Take a look at here.

    First page.

    
    
    
    
    
     
     
    
    
    

    Look in function choose I'm sent an id of textbox to the popup window (don't forget to add dummy data at last of URL param like &dummy=avoid#)

    Popup Page

    
    
    
    
    
    Car 
    Food

    I have add function getUrlVars for get URL param that the parent has pass to child.

    Okay, when select data in the popup, for this case it's will call function goSelect

    In that function will get URL param to sent back.

    And when you need to sent back to the parent just use window.opener and the name of function like window.opener.callFromDialog

    By fully is window.opener.callFromDialog(idFromCallPage,data);

    Or if you want to use window.opener.document.getElementById(idFromCallPage).value = data; It's ok too.

提交回复
热议问题