I have php page where the user can enter the mutual fund ticker symbol.
I am trying to enable the user to click a button and have the name of the fund display of the page.
I assume that I need to pass the value from the input box to a separate php page. I have a php page that uses php simple html dom parser and if I hard code the ticker symbol the php page will extract the name of the fund from a web page.
I am not clear on the concept of how I pass the variable from the input box to the the other php file or whether I even need a separate php file.
Is it possible to keep this all on the same php page? Right now, on the separate php page, I have a variable that holds the fund name.
I'm not sure how to display that value on the first php page. If somebody could help me with the concept, I can write some code.
Below is the page named getFundName.php
which gets the fund name.
<?php
include('simple_html_dom.php');
$firstvar = "http://www.marketwatch.com/investing/fund/";
$secondvar = "LLPFX";
$combovar = $firstvar . $secondvar;
$html = new simple_html_dom();
$html->load_file($combovar);
$getFundName = $html->find('#instrumentname',0);
print_r($getFundName->plaintext);
//echo $getFundName->plaintext;
$html->clear();
unset($html);
?>
Below is my guess at the other code, but obviously it's not functioning.
<?php
some php code here
?>
<html>
<body>
<script language="JavaScript">
function getFundName() {
var xhr=createXHR();
xhr.open("GET", "getFundName.php",true);
xhr.onreadystatechange=function()
{
if(xhr.readyState == 4)
{
document.getElementById("displayFundNameHere").innerHTML= xhr.responseText;
}
};
}
</script>
<div id="displayFundNameHere"><div>
Fund Symbol: <input type="text" id='fundSymbolBox'/>
<input type="button" value="Get Fund Name" onclick="getFundName()"/>
</body>
</html>