我觉得这应该是世界上最简单的事情.我只想制作一个带有onclick调用的按钮,让它运行javascript.然而,每次我这样做,我得到Uncaught TypeError:undefined不是函数错误.
我已经阅读了这个,但似乎不明白为什么它找不到这个功能.
回顾一下:按下按钮应该运行ThePush()但是我在控制台上出错了.
码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function ThePush() {
var name = document.getElementByID('name').value;
var pl = document.getElementByID('PL1').value;
var plw = document.getElementByID('theplw').value;
var al = document.getElementByID('theal').value;
//do stuff with these variables.
}
</script>
</head>
<body>
<b>Player One: </b><input id="name" type="text" value="Name"></input>
<br/><b>Level: </b><input id="PL1" style="width:50px" type="text" id="PL1L" value="0" readonly></input>
<br/>
<button id="thesub" onclick="ThePush();">Submit</button>
<select id="theplw">
<option value="A: 0-999">A: 0-999</option>
<option value="B: 1,000-9,999">B: 1,000-9,999</option>
<option value="C: 10,000-99,999">C: 10,000-99,999</option>
<option value="D: 100,000-499,999">D: 100,000-499,999</option>
<option value="E: 500,000-1,499,999">E: …Run Code Online (Sandbox Code Playgroud) 我正在创建一个应用程序,列出列表视图中附近的地址,但由于某种原因,地址不会进入列表.我错过了地址集的内容还是?...
它发生在for循环中.我希望它能够读取我得到的地址列表,并将我想要的信息仅修改为必要的位,例如街道号码和邮政编码,而不是大量的数字.
然而,每次我运行应用程序时,列表仍为空白.
package com.atonea.ps;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import android.app.Activity;
import android.content.Context;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class PSActivity extends Activity {
protected static final Location Location = null;
/** Called when the activity is first created. */
String location_text="";
String here="";
final ArrayList<String> addressbook = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) …Run Code Online (Sandbox Code Playgroud)