2
자바 스크립트를 처음 시도하는 것이지만 약 두 시간 후에 내가 어떤 실수를하는지 알아낼 수 없었습니다. 작을 것이라고 확신하지만 JSFiddle에서 작동하지 않는 이유를 알아낼 수 없었습니다.예제 HTML + JS 양식이 작동하지 않습니다.
다음<form name="myForm" onsubmit="return validateForm()" method="post">
<!--Question Block One-->
Do you have a name?
<br>
Yes<input type="radio" name="first" value="yes">
No<input type="radio" name="first" value="no">
<br>
<input type="submit" value="Submit">
</form>
은 JS의 :
function validateForm()
{
var x=document.forms["myForm"]["first"].value;
if (x==null || x=="")
{
alert("Please answer the first question!");
return false;
}
else if (x=="yes")
{
alert("Thanks");
}
else if (x=="no"
{
alert("Sorry, we can't help");
}
}
오류 : 여기
는 HTML의{"error": "Shell form does not validate{'html_initial_name': u'initial-js_lib', 'form': <mooshell.forms.ShellForm object at 0x9b6da8c>, 'html_name': 'js_lib', 'html_initial_id': u'initial-id_js_lib', 'label': u'Js lib', 'field': <django.forms.models.ModelChoiceField object at 0x98e9c0c>, 'help_text': '', 'name': 'js_lib'}{'html_initial_name': u'initial-js_wrap', 'form': <mooshell.forms.ShellForm object at 0x9b6da8c>, 'html_name': 'js_wrap', 'html_initial_id': u'initial-id_js_wrap', 'label': u'Js wrap', 'field': <django.forms.fields.TypedChoiceField object at 0x9ccfe4c>, 'help_text': '', 'name': 'js_wrap'}"}
그리고 여기 년대 JS 바이올린 : http://jsfiddle.net/4WesX/
오 사랑을. 침대 시간. 편집 : 사실, 여전히 작동하지 않습니다. – EGHDK
@EGHDK HTML에 삽입 된 JavaScript 이벤트가 JSFiddle에서 실행되지 않기 때문에 Fiddle에서는 작동하지 않습니다. – mattytommo
Gotcha. 도움을 감사하십시오. 다시 한 번 감사드립니다. 편집 : 사실, 이제는 일반 웹 페이지에서 첫 번째 경고음을 계속 내 보냅니다. 아이디어? – EGHDK