简体   繁体   English

在表单加载时显示Ajax样本结果

[英]Displaying Ajax Sample Results as the Form Loads

I've set up a box to display results from an Ajax form, showing water data from US Geological Survey and using a Google chart. 我设置了一个框来显示Ajax表单的结果,显示来自美国地质调查局的水数据并使用Google图表。 Works great, but I want users to see some sample results when they first load the form instead of an empty box. 效果很好,但是我希望用户在首次加载表单而不是空框时看到一些示例结果。 Not sure how to do it. 不知道该怎么做。 Here's the code for the form: 这是表格的代码:

<table bgcolor="tan" width="480px" height="450px"><tr><td>
<h2>Current River Levels</h2></td><td>
<form>
<select name="users"; onchange="showUser(this.value); drawChart(this.value)";>
<option value="01598500">North Branch at Luke, MD</option>
<option value="01603000">North Branch at Cumberland, MD</option>
<option value="01610000">Potomac River at Paw Paw, WV</option>
<option value="01613000">Potomac River at Hancock, MD</option>
<option value="01619500">Antietam Creek at Sharpsburg, MD</option>
<option value="01638500">Potomac River at Point of Rocks, MD</option>
<option value="01648000">Rock Creek at Sherrill Drive, DC</option>
<option value="01646500">Little Falls, DC</option>
</select>
</form></td></tr><td colspan="2">
<div id="placeholder"></div>
<div id="placeholder2"></div>## 
<div id="chart" style="width:100%"></div>
<div id="txtHint"><b>Select a site or visit our <a href="../monitoring_map.php4" target="_blank">interactive map.</a></b></div>

The entire project is located here: http://www.riverexplorer.com/potomax/json_test_20.php 整个项目位于此处: http : //www.riverexplorer.com/potomax/json_test_20.php

Trigger the onchange event when the document is ready. 准备好文档时触发onchange事件。

$(function(){
    $('select[name="users"]').trigger('change');
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM