NetTalk Central

Author Topic: Setting values when clicking menu  (Read 5234 times)

ShanePeterson

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Setting values when clicking menu
« on: July 05, 2007, 01:25:33 PM »
I have 2 menu items under a main menu.  I am setting a value in the "onClick:" field in the template.  Each menu item sets a different value to the same variable.  The problem is that the value doesn't change depending on which menu item that is clicked.  Regardless of which item is clicked the value is always what the lower item in the menu is set as.  For example if you have a menu like this:

My Projects
My Tasks
View All Projects

If "My Projects" sets a value to No (p_web.SetValue('ViewAll','No')) and "View All Projects" sets the same value to Yes p_web.SetValue('ViewAll','Yes')), the value is always Yes regardless of which menu item you select.


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Setting values when clicking menu
« Reply #1 on: July 06, 2007, 04:58:12 AM »
Hi Shane,

that "on click" is for javascript code (ie it's embeded onto the web page) so you can't set a value in that.

To pass a value to a procedure via a menu item URL is to tag the parameters onto the URL like this;

'BrowseCustomers?ViewAll=yes'
or (of course)
'BrowseCustomers?ViewAll=no'

You can add multiple parameters using the & as a separator.
'BrowseCustomers?ViewAll=yes&paid=no'

In the BrowseCustomers procedure, at the top of the "GenerateBrowse" routine, you should "store" this value for future use.

if p_web.IfExistsValue('ViewAll')
  p_web.SetSessionValue('ViewAll',p_web.GetValue('Viewall'))
end

OR (in 4.27 or later) this can be simplified to
p_web.StoreValue('ViewAll')

Ok, so now the parameter is _passed_ and it's _saved_ into a session value. All that remains is to _use_ that session value wherever you want. (probably in the browse filter.)

Cheers
Bruce