Panos
asked on
Jquery function within function problem
Hello experts.
I'm trying to use a function inside a function but i get an undifined error.
I use one onclick function to open a popup and load a page inside the popup.
This page has "x" forms .
I add a submit button (to each form) with an onclick function:onclick="sendmess age(#curre ntrow#);re turn false;" . I was expecting to submit the form but i get "sendmessage is not defined"
All the scripting code (jquery and validation script) is in the parent div.
May be i could load in the popup window all the scripts again and put a separate -var sendmessage = function (x) - function but i need your solution-advice.
Any help?
I'm trying to use a function inside a function but i get an undifined error.
I use one onclick function to open a popup and load a page inside the popup.
This page has "x" forms .
I add a submit button (to each form) with an onclick function:onclick="sendmess
All the scripting code (jquery and validation script) is in the parent div.
May be i could load in the popup window all the scripts again and put a separate -var sendmessage = function (x) - function but i need your solution-advice.
Any help?
var showdialog = function (id) {
$("#popuploader").dialog({
autoOpen: false,
bgiframe: true,
title: "Test",
modal: true,
width: 450,
height: dh,
buttons: {
Cancel: function () {
$(this).dialog("close");
$(this).dialog("destroy");
},
}
});
var sendmessage = function (x) {
var d = "#myform_" + x;
var f = d.valid();
$(d, $(this)).validate({
rules: {
message: {
required: true
}
},
messages: {
message: {
required: requiredfield
}
}
})
if (f) {
var e = $("input#message_" + x).val();
var c = d.serialize();
$.post("customer_items/includes/sendmessage-action.cfm", c, function (g) {
if (g) { /*$(".mailloader").hide();*/
if (g == "sended") {} else {}
}
})
}
}
var a = $("#popuploader");
a.dialog("open");
a.load("customer_items/includes/showitems.cfm?Art_ID=" + id, function (c, e, d) {
if (e == "success") {
} else {
alert(errorload)
}
});
return false
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe you want to use the validate.js in order to validate some input fields, apparently you forgot to include the js into your file.
ASKER
Thank you very much for your help.
i solved the second js error
regards panos
i solved the second js error
regards panos
ASKER
alex_code i missed your post.
Here is the working code:
this.sendmessage = function (x) {
var tempd = "#offerform_" + x;
var d = $(tempd);
$(tempd).validate({
rules: {
message: {required: true}
},
messages: {
message: {required:requiredfield}
}
})
var f = d.valid();
if (f) {
var c = d.serialize();
$.post("customer_items/act ion/sendem ail-action .cfm", c, function (g) {
if (g) {
if (g == "sended") {
}
else {
}
}
})
}
}
Here is the working code:
this.sendmessage = function (x) {
var tempd = "#offerform_" + x;
var d = $(tempd);
$(tempd).validate({
rules: {
message: {required: true}
},
messages: {
message: {required:requiredfield}
}
})
var f = d.valid();
if (f) {
var c = d.serialize();
$.post("customer_items/act
if (g) {
if (g == "sended") {
}
else {
}
}
})
}
}
ASKER
The method is now accessible but i get a js error:
$(d, $(this)).validate is not a function
Can you please take a look at the this.sendmessage = function (x) ?
Open in new window