Loading ...
Sorry, an error occurred while loading the content.

1557Help With jSON

Expand Messages
  • dctonyburley
    Dec 13, 2010
      Hey Folks,

      Here is the URL for my test site - http://showmercyonus.appspot.com/transaction

      The second row is a combination of JSON & AJAX that renders some stock info. Right now I have the "DELL" stock symbol hard coded into the URI string.

      1. I need to find how to pass any stock symbol a user types into the textbox under the label called Symbol into the JSON Query and once the textbox losses its focus the JSON AJAX code runs again and renders the second row with update information based on the request along with populating the text-box under the Price label.
      The code for the HTML page is below.

      Thanks so much for any assistance that you may be able to provide me with.


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <link rel="stylesheet" type="text/css" href="static/style.css" media="screen" />

      <!--Start of JSON AJAX to populate code-->
      <script src="http://code.jquery.com/jquery-latest.js"></script>
      $("#symbol").text( data.symbol );
      $("#previousClose" ).text( data.previousClose );
      $("#open" ).text( data.open );
      $("#lastTrade").text( data.lastTrade );
      $("#lastTradeTime").text( data.lastTradeTime );
      $("#change").text( data.change );
      $("#daysLow").text( data.daysLow );
      $("#daysHigh").text( data.daysHigh );
      $("#volume").text( data.volume);

      <!--END of JSON AJAX to populate code-->

      <div id="header">
      <div id="menu">
      <ul id="nav">
      <li><a href="/">Dashboard</a></li>
      <li><a href="/portfolio">Portfolio</a></li>
      <li><a href="/transaction">Transaction</a></li>
      <li><a href="research">Research</a></li>
      <div id="content">
      <div id="right">
      <h2>Would you like to make a TRANSACTION?</h2>
      Please select the desired action (buy or sell), and fill in the boxes below.</br>
      The latest price information will be retrieved from Yahoo Finance. </br>
      Please click here if you need the complete table information of the stock names.


      <form action="/talk" method="post">
      <th width="100px">Symbol</th>
      <th width="100px" align="center">Side</th>

      <th width="100px">Type</th>
      <th width="100px">Quantity</th>
      <th width="100px">Price</th>
      <td align="center"><input name="symbol" type="text" size="8" maxlength="8" /></td>
      <td align="center">
      <select name="side">
      <option value="buy">Buy</option>
      <option value="sell">Sell</option>
      <td align="center"><span id="type">Stock</span></td>
      <td align="center"><input name="qty" type="text" size="8" maxlength="8" /></td>
      <td align="center"><input name="price" type="text" size="8" maxlength="8" /></td>
      <td><input type="submit" value="Place Order"/></td>

      <form method="post">
      <th width="100px" align="center">Symbol</th>
      <th width="100px" align="center">Side</th>
      <th width="100px" align="center">Type</th>
      <th width="100px" align="center">Quantity</th>
      <th width="100px" align="center">Price</th>
      {% for m in msg_list %} {# (3) #}
      <td align="center">{{ m.symbol }}</td>
      <td align="center">{{ m.side }}</td>
      <td align="center">Stock</td>
      <td align="center">{{ m.qty }}</td>
      <td align="center">{{ m.price }}</td>
      {% endfor %}

      <!--START CODE FOR - Div Tag Ans Table For AJAX INFO-->
      <div id="quote">
      <table cellspacing="0" cellpadding="3" border="1">
      <th>Last Trade</th>
      <th>Last Trade Time</th>
      <th>Previous Close</th>
      <th>Day's Low</th>
      <th>Day's High</th>
      <td id="symbol"></td>
      <td id="lastTrade"></td>
      <td id="lastTradeTime"></td>
      <td id="change"></td>
      <td id="open"></td>
      <td id="previousClose"></td>
      <td id="daysLow"></td>
      <td id="daysHigh"></td>
      <td id="volume"></td>
      <!--END CODE FOR - Div Tag Ans Table For AJAX INFO-->