0

windows.pageload イベント ハンドラーは、ページの読み込み時にページを送信します。私の意図は、フォーム送信ボタンがクリックされたときにイベントハンドラーを送信イベントに接続することです。私は何を間違えましたか?ありがとう!

function submit_data () {

var parent1Phone =              $("parent1Phone").value;

var areaCode = parent1Phone.substring(0,3);

var prefix = parent1Phone.substring(4,7);

var suffix = parent1Phone.substring(8,12);

var firstName =                     $("firstName").value;
var lastName =            $("lastName").value;
var sportID =                       $("sportID").value;
var entryFrom =                     $("entryFrom").value;
var linkSource =                    codeSource;
var primaryEmail =              $("primaryEmail").value;
var graduationYear =            $("graduationYear").value;
var postalCode =                    $("postalCode").value;
var parent1FirstName =      $("parent1FirstName").value;
var parent1LastName =       $("parent1LastName").value;
var parent1Relationship =   $("parent1Relationship").value;
var parent1Phone1=        areaCode;
var parent1Phone2 =       prefix;
var parent1Phone3 =       suffix;
var parent1PhoneType =      $("parent1PhoneType").value;                    //No validation required. No non-choice allowed.
var parent1Email =              $("parent1Email").value;
var parent1EmailConfirm =   $("parent1Email").value;
var successDestination =    success;
var errorDestination =      failure;

var url =   "http://recruit-  match.ncsasports.org/fasttrack/saefentry/submitFullFormRemote.go?";

window.location.href = url + "firstName="+ firstName + "&lastName=" + "&lastName=" + lastName +"&sportID=" + sportID + "&entryFrom=" + entryFrom + "&linkSource=" + linkSource + "&primaryEmail=" + primaryEmail +"&graduationYear=" + graduationYear + "&postalCode=" + postalCode + "&parent1FirstName=" + parent1FirstName + "&parent1LastName=" + parent1LastName + "&parent1Relationship=" + parent1Relationship + "&parent1Phone1=" + parent1Phone1 + "&parent1Phone2=" + parent1Phone2 + "&parent1Phone3=" + parent1Phone3 + "&parent1PhoneType=" + parent1PhoneType + "&parent1Email=" + parent1Email + "&parent1EmailConfirm=" + parent1Email + "&successDestination=" + successDestination + "&errorDestination=" + errorDestination;
}

function prepareEventHandlers() {
    $("frmNcsa").onclick = submit_data();
}

window.onload = function() {
    prepareEventHandlers();
}
4

1 に答える 1

0

submit_dataあなたは割り当てを呼び出しています$("frmNcsa").onclick = submit_data();、それはそうあるべきです$("#frmNcsa").click(submit_data);

jQuery 関数に渡されるすべての文字列が要素の ID であると仮定すると、先頭に#.

于 2012-09-05T01:38:48.083 に答える