I'm using C/CGI Programming with Linux Redhat.
I have an event handler which listens for Save, Delete, etc.
In my event handler, I want a JavaScript popup to confirm before the user Deletes a record.
Here's the Delete Code inside the event handler:
----------------------------------------------------
void event_handler() {
long sqlcode;
char *back;
// --- RESET BUTTON ---- //
if (!strcmp(evt_fld,"Reset") {
reset_scr();
put_state();
puthtml();
}
// ---- BACK BUTTON ---- //
else if (!strcmp(evt_fld,"Back") {
back = pop_backstack(&state);
strcpy(state.msg,""
put_state();
exec_cgi(back);
}
// --- DELETE BUTTON --- //
else if (!strcmp(evt_fld,"Delete") {
sqlcode = delete();
EXEC SQL COMMIT;
if (sqlcode == 0) {
back = pop_backstack(&state);
sprintf(state.msg,
"<font color=\"green\">%s: \"%s\"</font>",
"Successful Deletion of Purpose Code",
state.code);
put_state();
exec_cgi(back);
}
else {
state.sqlcode = sqlcode;
sprintf(state.msg,"delete() failed on code %s",state.code);
put_state();
exec_cgi("error"
}
}
-----------------------------------------------------
We're writing the html code dynamically from within a c program.
I don't know how to insert my code to submit the page.
Should I create a separate function or call the JavaScript like JavaScript: to submit the page?
Here's my function:
---------------------------------------------------------
function DeleteIt() {
if
(confirm ("Are you sure you want to delete the selected record?") {
document.forms[0].submit();
}
else {
return false
}
}
------------------------------------------------------
Thanks
John
I have an event handler which listens for Save, Delete, etc.
In my event handler, I want a JavaScript popup to confirm before the user Deletes a record.
Here's the Delete Code inside the event handler:
----------------------------------------------------
void event_handler() {
long sqlcode;
char *back;
// --- RESET BUTTON ---- //
if (!strcmp(evt_fld,"Reset") {
reset_scr();
put_state();
puthtml();
}
// ---- BACK BUTTON ---- //
else if (!strcmp(evt_fld,"Back") {
back = pop_backstack(&state);
strcpy(state.msg,""
put_state();
exec_cgi(back);
}
// --- DELETE BUTTON --- //
else if (!strcmp(evt_fld,"Delete") {
sqlcode = delete();
EXEC SQL COMMIT;
if (sqlcode == 0) {
back = pop_backstack(&state);
sprintf(state.msg,
"<font color=\"green\">%s: \"%s\"</font>",
"Successful Deletion of Purpose Code",
state.code);
put_state();
exec_cgi(back);
}
else {
state.sqlcode = sqlcode;
sprintf(state.msg,"delete() failed on code %s",state.code);
put_state();
exec_cgi("error"
}
}
-----------------------------------------------------
We're writing the html code dynamically from within a c program.
I don't know how to insert my code to submit the page.
Should I create a separate function or call the JavaScript like JavaScript: to submit the page?
Here's my function:
---------------------------------------------------------
function DeleteIt() {
if
(confirm ("Are you sure you want to delete the selected record?") {
document.forms[0].submit();
}
else {
return false
}
}
------------------------------------------------------
Thanks
John