开发者

Get php variable from inline frame

I have an inline frame within a form. The inline frame actually contains the form element which is generated programatically (a radio which holds a value). How can I retrieve that value hold by the radio from the page which contains that inline 开发者_高级运维frame. Any idea? thanks for reading


What MvanGeest is suggesting is for you to use javascript to transfer values of the radio buttons to a hidden field in your main page form so for each radio button you would have onclick="valueSet(this.value)" and in the function valueSet (that you define in the iframe) you would set the value of the hidden form field

function valueSet(radioValue){
    window.parent.document.forms["nameOfYourForm"].elements["nameOfHiddenElement"].value = radioValue;
}

and in the main window, in the FORM you have
<input type="hidden" name="nameOfHiddenElement" value="" />

and you can set the default value for it as well

Don't forget to give your form a name attribute and use that name in the function where it references forms["nameOfYourForm"]

Does that make sense for your project? Or am I totally off base here?


This site explains about cross-frame access in JavaScript: http://www.west-wind.com/Weblog/posts/589454.aspx. Be aware that the same-origin policy is enforced; in other words, you cannot access a frame which contains a page loaded from another domain.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜