/    Sign up×
Community /Pin to ProfileBookmark

I’m trying to make a small stock quote checker. Could anyone tell me what’s wrong with this code? Thanks a whole lot in advance. ^_^

<html>
<head>
<title>Branden’s Widget</title>
<script type=”text/javascript”>
var tickersymbol = document.getElementById(“stockname”).value
var xmlhttp;
function loadXMLDoc(“http://finance.yahoo.com/q?s=” + tickersymbol)
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for all new browsers
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5 and IE6
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open(“GET”,url,true);
xmlhttp.send(null);
}
else
{
alert(“Your browser does not support XMLHTTP.”);
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = “loaded”
if (xmlhttp.status==200)
{// 200 = OK
var allsourcecode=xmlhttp.responseText
var stock1=allsourcecode.split(“<span id=”)
var stock2=stock1[7].split(“>”)
var stock3=stock2[1].split(“</span>”)
var finalquotebox=document.getElementById(“finalquote”)
finalquotebox.value=tickersymbol + ” ” stock3[0]
}
else
{
alert(“Problem retrieving XML data”);
}
}
}
</script>
</head>
<body bgcolor=”black”>
<center>
<font color=”silver”><h2>Get a Stock Quote!</h2><br>
Stock: <input type=”text” id=”stockname” value=”Ticker Symbol”><input type=”submit” value=”Get Stock Quote!” onClick=”loadXMLDoc()”><br><br>
<input type=”text” id=”finalquote” value=”The Stock Quote”>
</center>
</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rpgfan3233Mar 09.2009 — function loadXMLDoc("http://finance.yahoo.com/q?s=" + tickersymbol)

{[/quote]

I think you meant to define the loadXMLDoc() function, not call it. :p

In the future when you post HTML tags, it would be appreciated if you could use the &#91;html&#93; &#91;/html&#93; tags or &#91;code&#93; &#91;/code&#93; for pretty much any code.

Hope this helps! ^_^
×

Success!

Help @yomamacableguy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...