NetTalk Central

Author Topic: Hide Field Question  (Read 5153 times)

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Hide Field Question
« on: August 13, 2018, 01:44:02 PM »
is possible hide a field according if mobile or desktop in a form

NT 10.29

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: Hide Field Question
« Reply #1 on: August 13, 2018, 02:52:08 PM »
In the field's hide field:

p_web.IsMobile() = 1  !Hide if in Mobile Mode

p_web.IsMobile() = 0  !Hide if Desktop Mode

If you choose to not use jQuery Mobile take a look at CSS media queries:

In, for example, a custom.css file.

@media only screen and (max-width: 600px) {
    .mycustomclass {
        visibility: hidden;
    }
}

https://www.w3schools.com/cssref/css3_pr_mediaquery.asp

Don

"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Hide Field Question
« Reply #2 on: August 13, 2018, 04:41:58 PM »
not work because my site is configured only desktop mode but with responsive, but with userAgent i capture if window version and hidden a field, look

http://track.magictransport.com:88/ShipmentTracking

try with 1312020 in desktop mode display a field with a progress of shipment and in mobile device the field is hidden

thanks..

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Hide Field Question
« Reply #3 on: August 14, 2018, 06:52:31 AM »
Hi Osa,

As you say, jQueryMobile is deprecated, so keep it in "desktop" mode.

>> but with userAgent i capture if window version

don't do that. User Agents are changing all the time, so over the years your program will "rot".
The better approach is the other half of Don's reply - use media queries.

@media only screen and (max-width: 600px) {
    .mycustomclass {
        visibility: hidden;
    }
}

This allows you to hide/unhide things based on the _screen size_ which is really what it's all about.
There are some classes built-in which will help with this.

if-not-small,
if-large
if-medium

So for example, if you want a field to disappear when the screen is small add the class if-not-small to it. Or if you want a field to appear only if the screen is large then use if-large on it and so on.

The key is;
a) stop thinking about "mobile" and "desktop" - we need to stop thinking of those terms.
b) think about "screen size" - that's really all that matters... because screen size changes the _tasks_ that we do with the device.

cheers
Bruce

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Hide Field Question
« Reply #4 on: August 15, 2018, 04:57:53 AM »
thanks with if-not-small work perfectly