I'm new to javascript.
I have a JavaScript function, which returns me the name of the country. Now I have to put this value in IFAM's src. My Javascript function is as follows:
& lt; Script type = "text / javascript" & gt; Var Country = $ ("# SCountry"). Val (); Function getCountry () {var country = $ ("# SCountry"). Val (); Return country; } & Lt; / Script & gt; I am getting the value of the country but it can not be included in the source of IRAM. My iframe src is as follows:
src = 'https: //example.com/? Country = "javascript: getCountry ()" ' This is not working.
You give an ID for this kind of "content" iframe of your iframe) This is a pure JS The solution is:
document.getElementById ("iframe_id"). ContentDocument.getElementById ("destination_id"). InnerHTML = Country; And your iframe tag can look like this:
& lt; Iframe src = 'https: //domain.com/' id = "iframe_id" & gt; `` And lieutenant Php: JS:
with `document.getElementById ('iframe_id'). Src = 'https://domain.com/?country=' + country; ` PHP in the iframe: $ country = $ _POST [ "Country"]; Echo $ country; // This is the echo you can use where you want to show results
No comments:
Post a Comment