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

Help With jSON

Expand Messages
  • dctonyburley
    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
    Message 1 of 1 , Dec 13, 2010
    • 0 Attachment
      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.

      Tony


      <?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">
      <head>
      <head>
      <title>MyCashIsLost</title>
      <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>
      <script>
      $(document).ready(function(){
      $.getJSON("http://mdbitz.com/testing/PHPYahooFinance/finance.php?symbol=DELL&callback=?",
      function(data){
      $("#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);
      }
      );
      });
      </script>


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


      </head>
      <body>
      <div id="header">
      <h1>MyCashIsLost</h1>
      <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>
      </ul>
      </div>
      </div>
      <div id="content">
      <div id="right">
      <h2>Would you like to make a TRANSACTION?</h2>
      <p>
      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.

      </p>


      <form action="/talk" method="post">
      <fieldset>
      <table>
      <thead>
      <tr>
      <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></td>
      </tr>
      </thead>
      <tr>
      <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>
      </select>
      </td>
      <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>
      </tr>
      </table>
      </fieldset>
      </form>

      <form method="post">
      <fieldset>
      <table>
      <thead>
      <tr>
      <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>
      <td></td>
      </tr>
      </thead>
      {% for m in msg_list %} {# (3) #}
      <tr>
      <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>
      </tr>
      {% endfor %}
      </table>
      </fieldset>
      </form>


      <!--START CODE FOR - Div Tag Ans Table For AJAX INFO-->
      <div id="quote">
      <table cellspacing="0" cellpadding="3" border="1">
      <tr>
      <th>Symbol</th>
      <th>Last Trade</th>
      <th>Last Trade Time</th>
      <th>Change</th>
      <th>Open</th>
      <th>Previous Close</th>
      <th>Day's Low</th>
      <th>Day's High</th>
      <th>Volume</th>
      </tr>
      <tr>
      <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>
      </tr>
      </table>
      </div>
      <!--END CODE FOR - Div Tag Ans Table For AJAX INFO-->
    Your message has been successfully submitted and would be delivered to recipients shortly.