여러 매개 변수를 전달하는 양식이 있습니다. 지금까지 주식 매개 변수가 전달되고있다 : I은이 매개 변수 문자열에 추가로 폼 요소를 추가하려고 해요JavaScript를 통해 양식에 매개 변수 전달
var params = "title=" + document.getElementById("title").value +
"&url=" + document.getElementById("url").value +
"&snippet=" + document.getElementById("snippet").value +
"&tags=" + document.getElementById("tags").value +
"&status_bookmark=" + document.getElementById("status_bookmark").value +
"&comment=" + document.getElementById("comment").value +
"&status_comment=" + document.getElementById("status_comment").value;
: 여기
var i, lng = document.getElementById('addbookmark').length;
// If the length property is undefined, then there is only one checkbox.
if (typeof lng === "undefined") {
params + "&topic-link-item-1=" + document.getElementById("topic-link-item-1").value;
params + "&topic-link-comment-box-1=" + document.getElementById("topic-link-comment-box-1").value;
}
else {
for (i = 0; i < lng; i++) {
params + "&topic-link-item-" + i + "=" + document.getElementById("topic-link-item-" + i).value;
params + "&topic-link-comment-box-" + i + "=" + document.getElementById("topic-link-comment-box-" + i).value;
}
}
을, 나는 코드에서 가져온 사용했습니다 another StackOverflow article에서 볼 수 있듯이, jQuery를 통해 다른 곳에서 생성하는 임시 양식 요소와 일치하는 일련의 쌍을 이루는 매개 변수를 작성하려고합니다.
그러나 이러한 값은 다른 양식 요소가 전달되는 동안 양식을 통해 전달되지 않는 것처럼 보입니다.
제안 사항?
업데이트 내가 제안에 따라 코드를 수정했습니다
,하지만 작동하지 않는 : 폼으로
var i, formObj = document.form['addbookmark'], formObjLng = document.form['addbookmark'].length;
// If the length property is undefined, then there is only one checkbox.
if ((typeof formObjLng !== "undefined")) {
for (i = 0; i < formObjLng; i++) {
if ((formObj.elements['topic-link-item-' + i].type == "checkbox") && (formObj.elements['topic-link-item-' + i].checked)) {
params = params + "&topic-link-item-" + i + "=" + encodeURIComponent(document.getElementById("topic-link-item-" + i)).value;
params = params + "&topic-link-comment-box-" + i + "=" + encodeURIComponent(document.getElementById("topic-link-comment-box-" + i)).value;
}
}
}
, 단순히 "addbookmark"의 ID와 양식의 , 그리고 이전에 내가 말한 것을 다시 말하면, 모든 것은 여기서 시도한 것을 제외하고는 모두 작동합니다.
가 어디 "형태"당신이 언급되어있을 하는가? 실제 HTML 양식 요소가 있습니까? –
양식 [POST] (http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods) 또는 [GET] (http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods)이 맞습니까? 서버 측 코드가 POST를 기다리고 있다면 GET을 통해 매개 변수를 전달하는 것이 효과가 없을 것입니다. – JDB
addbookmark 란 무엇입니까? 양식 요소 인 경우 form [ 'name']. 요소 [ 'elementname']. 형식을 사용하여 양식 요소 유형 (확인란 등)을 검색합니다. – KrisWebDev