NetTalk Central

Author Topic: How to trigger a button in a Browse from a link(DropMenu)?  (Read 5117 times)

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
How to trigger a button in a Browse from a link(DropMenu)?
« on: September 25, 2018, 10:39:25 PM »
Hallo!


I would like to implement a small drop menu on my Browse instead of adding buttons and when I press a link to trigger a button for different actions.
I like this example: https://www.w3schools.com/css/css_dropdowns.asp

My idea is:
1.Add some buttons with my code that I want.
2.Hide this buttons
3.Create the drop menu like in the above example
4.When I press the link1 I would like to trigger the button1 , link 2 > button2, .... and so on.

I found some code on internet that works for the first row, but not for the rest...
Maybe I omitted something very easy to do here... I think I need the correct embed to put code maybe...

Also to trigger a button you need the ID. The ID is changed every time the browse refresh.
(I did not find the parameter that return the ID and instead I parse the packet and extract the ID...)
What is the best method to get the ID of a button?

ref: https://www.quora.com/How-do-I-trigger-a-click-on-a-link-using-jQuery
This is the code I test: https://jsfiddle.net/cLd4ecz8/1/


Thank you for any help/suggestions!
Robert

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: How to trigger a button in a Browse from a link(DropMenu)?
« Reply #1 on: September 26, 2018, 01:56:47 AM »
Hi Robert,

Have you considered calling the "action" in your own code (popup menu), Rather than hide the buttons and then programatically click them?

Certain internal NT actions are relatively simple (some are not), so it might depend upon what actions you are trying to perform.

Add,Change,Delete and View either as whole pages or popups are "fairly" straight forward. Not sure about print or export etc (since I haven't tried).

Also, I understand this isn't perfect as Bruce could change the way some internal functions work and this could break your code (but can can abstract this, sometimes you can even piggyback onto Bruces' own functions).


Regards
Bill

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: How to trigger a button in a Browse from a link(DropMenu)?
« Reply #2 on: September 26, 2018, 05:29:46 AM »
Hallo Bill,

>>Certain internal NT actions are relatively simple (some are not), so it might depend upon what actions you are trying to perform.
I try to open some reports.

>>Have you considered calling the "action" in your own code (popup menu), Rather than hide the buttons and then programatically click them?
Yes, but I encountered some issue.

I create a link where I call the ServerDocument procedure:
Code: [Select]
<a href="ServeDocument?report=FacturaTVA"><i class="far fa-file-pdf"></i>&#160;&#160; Factura cu TVA</a>
In ServerDocument procedure I read the parameter and then call the Report procedure.
Please see bellow my code:
 
Code: [Select]
CASE p_web.GetValue('report')
  OF 'FacturaTVA'
    INV:GUID = p_web.GSV('INV:GUID')
    R_Invoice_Extern_PDF(p_web)
    IF p_web.GSV('w-RecordsNotFound') = 1
      p_web.SSV('w-RecordsNotFound',0)
      p_web.Script('ntAlert("Nu exista informati disponibile pentru acest raport!","Atentie");')
      stt.Trace('nu exista informatii')
    ELSE
      loc:filename = p_web.GSV('PDFname')
      p_web.HeaderDetails.ContentDisposition = 'attachment; filename="'& p_web.GSV('report-filename') &'"'
    END

It works very well just that if the reports has no records it will crash/close the WebServer. (The WebServer will close automaticaly)
I have no idea what could cause this.

Usually I call the reports procedure (R_Invoice_Extern_PDF(p_web)) before to call ServeDocument but in this case I don't know how to do it.
From buttons I never got problems with Reports.

Thank you!
Robert

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: How to trigger a button in a Browse from a link(DropMenu)?
« Reply #3 on: September 26, 2018, 11:39:05 PM »
Hi Robert,

Ok I see what you are doing.

I hand code reports and have a system similar to your ServeDocument function that manages the process for me, so in that respect we are similar.

If the server crashes, have you checked for any function that fails to return a value (I know its obvious, but i still do this occasionally!)

I dont see anything special in the way you are doing things that would cause a problem.

What type of  procedure is ServeDocument?

Do you route all your reports through ServeDocument even when using buttons?

Regards
Bill

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: How to trigger a button in a Browse from a link(DropMenu)?
« Reply #4 on: September 27, 2018, 08:10:20 AM »
Hallo Bill,


>>I hand code reports and have a system similar to your ServeDocument function that manages the process for me, so in that respect we are similar.
Thank you for confirmation.

>>What type of  procedure is ServeDocument?
ServeDocument it's a NetWebPage procedure type.

>>Do you route all your reports through ServeDocument even when using buttons?
Yes. Only that for buttons I call the reports procedure on the button not on ServeDocument.
Should I use a different ServeProcedure for this?

Thank you!
Robert