Can I have two JavaScript onclick events in one input type button tag?

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
IMPORTANT NOTE!!

DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.



PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
Post Reply
lummis
 
 
Posts: 211
Joined: Sun Apr 24, 2011 9:18 am
Location: UK

Can I have two JavaScript onclick events in one input type button tag?

Post by lummis »

I am attempting to run two JavaScript events when using onclick. The events are "mySqlDelete()" and "window.location.href='http://www.mydomain.com' ".

I have tried with using " mySqlDelete(); window.location.href='http://www.mydomain.com' " but the second event is not actioned although both parts work independently if I remove one event.

Any suggestions please.

Brian
User avatar
Pablo
 
Posts: 21578
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by Pablo »

This should work because this is standard HTML functionality.
Maybe you have made a type error?
You can use the browser's debugger (F12) to see what is wrong.
lummis
 
 
Posts: 211
Joined: Sun Apr 24, 2011 9:18 am
Location: UK

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by lummis »

The browsers debugger is not showing any errors and I am sure that I had it working a couple of months ago when testing. I can't think of any changes that I have made that would affect things. Is there a workaround which would achieve what I am trying to do i.e. moving to another page after the database deletion?
User avatar
Pablo
 
Posts: 21578
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by Pablo »

If you need further assistance then please share a demo project so I can see what you have done.

Read this carefully before sharing:
http://www.wysiwygwebbuilder.com/forum/ ... 10&t=82134
lummis
 
 
Posts: 211
Joined: Sun Apr 24, 2011 9:18 am
Location: UK

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by lummis »

As requested here is the wbs file stripped down.

https://www.stowaways.org/StowawaysDeletePage.wbs

The project does include the SQL connector extension in the opening page as it is an integral part.

The purpose of the page is twofold. First to delete an entry in a database and secondly to mail an advice to the sender and the webmaster. The second part is achieved by redirecting to the page "delete_entry_mailing", which contains the standard form mailer, and the button on that page is automatically clicked via a script.

As previously stated , the two functions for the onclick event in the first page work when used separately but do not redirect to the second page when combined.

Have I over-complicated the process or is there another way?
User avatar
Pablo
 
Posts: 21578
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by Pablo »

The reason why this does not work is because mySqlDelete() reloads the page, so in this case all code after the function is ignored by the browser.
lummis
 
 
Posts: 211
Joined: Sun Apr 24, 2011 9:18 am
Location: UK

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by lummis »

If that is the case, is there a way I could arrange the redirect after the page has been reloaded?
User avatar
Pablo
 
Posts: 21578
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by Pablo »

There is no standard solution for this becuase you will have to keep track of what the last action was (with cookies or webstorage) before the page gets reloaded. This can only be done with custom code.
lummis
 
 
Posts: 211
Joined: Sun Apr 24, 2011 9:18 am
Location: UK

Re: Can I have two JavaScript onclick events in one input type button tag?

Post by lummis »

Thanks Pablo, at least I know why the onclick function was not working. I will try to think of another way or just abandon the emails about the deletion.
Post Reply