검색 상자에 대한 팝업을 작성하고 양식에 키워드를 제출하려고합니다. 인터넷에서 유사한 질문을 찾아 보았지만 적용한 유일한 해결책은 양식의 요소 제출을 삭제하는 것입니다. 그것은 둘 다 잘 작동하지 않았습니다. 어떤 아이디어?자바 스크립트에서 제출을 실행할 수 없습니다.
django에서 작업하고 자세한 내용을 제공 할 수 있습니다.
내 자바 스크립트의 일부는 다음과 같습니다
$("#dialog-form").dialog({
autoOpen: false,
height: 200,
width: 200,
modal: true,
buttons: {
"Search": function() {
var bValid = true;
allFields.removeClass("ui-state-error");
bValid = bValid && checkLength(keyword, "username", 2, 16);
bValid = bValid && checkRegexp(keyword, /^[a-z]([0-9a-z_])+$/i, "Keyword may consist of a-z, 0-9, underscores, begin with a letter.");
if (bValid) {
document.getElementById('searchForm_1_keyword').value = keyword.val();
document.getElementById('searchForm').submit(); //if I comment out this line it continues the next line, if not, it does not execute the next line
$("#testDiv").append("<tr>" +
"<td>" + keyword.val() + "</td>" +
"</tr>");
alert(keyword.val());
$(this).dialog("close");
}
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function() {
allFields.val("").removeClass("ui-state-error");
}
});
및 HTML은 다음과 같습니다
<div class="searchBox">
<form id='searchForm' method="POST" action="/dasdasasdas/" >{% csrf_token %}
<input type="text" name="column_name" value='supplier_name'>
<input type="text" name="keyword" id="searchForm_1_keyword" value=""/>
</form>
</div>
이러한 내 JQuery와 파일입니다
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>
이 해결책을 찾았을 !
나는 신참 한 실수를 저질 렀습니다. 나는 중첩 된 형태를 가졌다. 실수를 바로 잡으면 작동합니다. 당신이 jQuery를에 액세스 할 때 왜
document.getElementById('searchForm').submit()
를 사용하는
어떤 브라우저를 사용합니까? – Topera