NetTalk Central

Author Topic: Help with Buttons...  (Read 6010 times)

webwilcox

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • Email
Help with Buttons...
« on: April 03, 2013, 05:34:53 AM »
I have a form that runs as a popup to a browse.  I want to put some buttons on that form called "Start Task" and "Complete Task".  When I click the "Start Task" button, it should update some fields and save and close the form.  Same for the "Complete Task" button.

I have set the button type as "Button" and can get the code to update the fields working fine, but it doesn't save and close.  When I set the button type to "Submit", it wants me to enter a URL and I'm not sure what to put for the URL.  I've looked at the nettalk example for Buttons but something just isn't clicking for me.

Any help would be appreciated.

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Help with Buttons...
« Reply #1 on: April 03, 2013, 10:34:59 AM »
Hi WebWil,

Your clue is here:

  p_web.site.SaveButton.TextValue = 'Login'

ie, normal Form and change the Text on the Buttons.

Cheers
Charl

webwilcox

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • Email
Re: Help with Buttons...
« Reply #2 on: April 03, 2013, 01:17:40 PM »
Charl99,
   Thanks so much for the reply.  Doesn't that just allow me to change the text of the save button ?   What I'm really looking to do is have multiple save button with different fields being automatically modified based on which save button they push.

For example,  when a user pushes the "Start Task" save button, the StartDate, StartTime and Status field are appropriately set and the form is saved and returned to the browse.  Likewise, when the user pushes the "End Task" save button, the EndDate, EndTime and Status fields are set appropriately and the form is saved and returned to the browse.

I have the server side code running properly, but don't know the best way to create these multiple save buttons.

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Help with Buttons...
« Reply #3 on: April 03, 2013, 02:47:27 PM »
maybe you could use radio buttons for your different options and then use the std save button

webwilcox

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • Email
Re: Help with Buttons...
« Reply #4 on: April 04, 2013, 05:04:11 AM »
I considered that, but I was wanting to make it as "idiot" proof as possible.

Is there a way, through code, to press the standard save button ?

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Help with Buttons...
« Reply #5 on: April 04, 2013, 05:20:23 AM »
It sounds like you are trying to Set a Filter, Check the

Using a Form as the Criteria for a Browse

in the Book.  The Book also says - The Dropfilter (33) example contains a form (FilterAlias) which in turn is used to filter the browse.

Hope this helps.

Charl

webwilcox

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • Email
Re: Help with Buttons...
« Reply #6 on: April 04, 2013, 12:13:20 PM »
I don't think that is what I'm looking for.  Attached is a screen print of my form that runs as a popup.

- When a user presses the "Start Task" button, I want to set the start date, start time and status fields and save and close the form and return to the browse.

- When a user presses the "Complete Task" button, I want to set the end date, end time and status fields and save and close the form and return to the browse.

I have the logic working for the standard save button to set fields but don't know how to make this work with multiple save buttons.

[attachment deleted by admin]

Poul

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Help with Buttons...
« Reply #7 on: April 04, 2013, 12:18:41 PM »
What an interesting problem,
Here is what i came up with nt 7.07..
In the Source Embeditor paste this above where your savebutton is generated
(you said popup, so  put it in the FormHeading Routine )
near
! End of "Form Button Set : 2 Save"
!  Start of "Form Button Set : 2a JavaScript"
! [Priority 5000]

p_web.site.SaveButton.TextValue = clip('Start Task')
packet = clip(packet) & p_web.CreateStdButton('button',Net:Web:SaveButton,loc:formname,,,loc:javascript)
p_web.site.SaveButton.TextValue = clip('End Task')
packet = clip(packet) & p_web.CreateStdButton('button',Net:Web:SaveButton,loc:formname,,,loc:javascript)
p_web.site.SaveButton.TextValue = clip('Save')  SaveButton.TextValue = clip('Save')    


(if your CreateStdButton for the Savebutton is different,  chnage this to match it to what is generated.
that will give you two more save buttons with the labels you want.
now, to do your custom code for each scenario,
put this at the bottom of ValidateRecord routine
near"  ! End of "On Insert & Update : Form ends : before disk write"   
 

 Case p_web.getvalue('_buttontext_')
   of 'Start Task'
    ! Test:Jobstatus = 'Task Started'      !do your stuff here
   of 'End Task'
       !Test:Jobstatus  = 'Task finished'      !or here
 end


the "_buttontext_" is the magic stuff
poul

webwilcox

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • Email
Re: Help with Buttons...
« Reply #8 on: April 04, 2013, 02:34:51 PM »
Poul,

That did the trick.  Thank you so much for your help.