Search code examples
javascriptdjangorenderphone-numbertel

Django - how to call a phone number AND open a form page with one click?


I hope to get ist straight: I have a Django app with customer addresses and 'activities' whoch protocolls any contact to customers via email or phone. When the user clicks on a phone number (link) I want the system to dial that number and at the same time to create a record in a table (activities), render another page with a form, where he writes down notes while talking to the customer.

How can I do that without a second click?

I know, I create a link <a href='tel:{{ customer.phone }}'> that much is clear. But how to do a second action on the same click? Probably with JavaScript (I use jQuery, but am a novice to JavaScript).

Alternatively I thought I could call the "Call-Phone-Number" action in a view which is called by the link (instead of 'tel:...') in the first place and does all the form rendering, which is more comfortable for me. But how to call a phone number from a view in python and render a page simultaniously (or one after the other without waiting) ?

I hope my situatuon is clear...

Thanx for any help!


Solution

  • You could try the following JS:

    window.onload = function(e){
                window.location.href = your_url
                return false;
            }
    

    This will basically be like the user clicking on that link.