我默认禁用了一个文本框,我想在下拉的onchange()事件中启用它。
我试过这个但没有工作:
service_account_mail = 'xxxxxx@developer.gserviceaccount.com'
service_account_client_id = 'xxxxxx.apps.googleusercontent.com'
with open("private_key.p12") as f:
private_key = f.read()
gapps_scope=[
'https://www.googleapis.com/auth/drive',
'https://apps-apis.google.com/a/feeds/emailsettings/2.0/',
]
credentials = SignedJwtAssertionCredentials(service_account_mail, private_key, gapps_scope)
print credentials.access_token
None
credentials.get_access_token()
credentials.access_token
Now I get something useful
headers = {
'Authorization': 'Bearer ' + credentials.access_token,
'Content-type': 'application/atom+xml'
}
url_tpl = """https://apps-apis.google.com/a/feeds/emailsettings/2.0/mydomain.com/%s/%s"""
url = url_tpl % (myusername, 'label')
r = requests.get(url, headers=headers)
403 - 'You are not authorized to access this API.'
body_tpl = """<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="signature" value="%s" />
</atom:entry>"""
url = url_tpl % (myusername, 'signature')
payload = body_tpl % 'Test'
r = requests.put(url, headers=headers, data=payload)
403 - 'You are not authorized to access this API.'
r = requests.get(url, headers=headers)
403 - 'You are not authorized to access this API.'
drive_url = "https://www.googleapis.com/drive/v2/files"
headers = { 'Authorization': 'Bearer ' + credentials.access_token, }
r = requests.get(drive_url, headers=headers)
200 - 'OK'
什么是正确的?
答案 0 :(得分:1)
Javascript是区分大小写的语言。
代码中的问题是函数名称拼写错误
onchange="myfunction()"
并在javascript(通知大写F
)
function myFunction() {
更改功能名称,然后它将起作用。
function myFunction() {
document.getElementById("myText").disabled = false;
}
Name:
<input type="text" id="myText" disabled="true">
<p>Click the button to disable the text field.</p>
<select onchange="myFunction()">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
另外,使用addEventListener
绑定事件。
答案 1 :(得分:1)
JavaScript中的符号区分大小写。您已将功能命名为myFunction
,但尝试使用myfunction
调用它。
此外,不使用内联事件处理程序!在JavaScript部分中使用.addEventListener()
,如下所示:
function enableText() {
document.getElementById("myText").disabled = false;
}
// You'll need to add a class name to your select
document.querySelector('.mySelect').addEventListener('change', enableText);
function enableText() {
document.getElementById("myText").disabled = false;
}
// You'll need to add a class name to your select
document.querySelector('.mySelect').addEventListener('change', enableText);
Name:
<input type="text" id="myText" disabled="true">
<p>Click the button to disable the text field.</p>
<select class="mySelect">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
答案 2 :(得分:0)
java脚本是区分大小写的语言,只需将函数myFunction()更改为函数myfunction()
即可
function myfunction() {
document.getElementById("myText").disabled = false;
}
<html>
<body>
Name:
<input type="text" id="myText" disabled="true">
<p>Click the button to disable the text field.</p>
<select onchange="myfunction()">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</body>
</html>