Share your advanced knowledge/code with the community.
User avatar
Peter
 
Posts: 625
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Set Placeholder-Attribute for StringGadget

by Peter Thu May 01, 2014 3:24 pm

Image

//Edit: Code removed. See the Posting from Fred below.

Greetings ... Peter
Last edited by Peter on Thu Jun 02, 2016 4:24 pm, edited 1 time in total.
falsam
 
Posts: 275
Joined: Mon May 05, 2014 9:49 pm
Location: France

Re: Set Placeholder-Attribute for StringGadget

by falsam Wed Jun 01, 2016 11:37 am

Hello Peter ;)

Your code no longer works. I suggest the new code.
Code: Select all
Procedure SetStringGadgetPlaceholder(Gadget, Placeholder.s)
  !$('#dijit_form_TextBox_' + v_gadget).attr('placeholder', v_placeholder);
EndProcedure

OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 200, "Enter address", #PB_Window_ScreenCentered)

StringGadget(0, 10, 10, 200, 20, "")
SetStringGadgetPlaceholder(0, "First name")

StringGadget(1, 10, 40, 200, 20, "")
SetStringGadgetPlaceholder(1, "Last name")

StringGadget(2, 10, 70, 200, 20, "")
SetStringGadgetPlaceholder(2, "Phone number")


Greeting .... falsam ^^

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
falsam
 
Posts: 275
Joined: Mon May 05, 2014 9:49 pm
Location: France

Re: Set Placeholder-Attribute for StringGadget

by falsam Wed Jun 01, 2016 11:56 am

Oops !! it does not work with this example.
Code: Select all
Enumeration
  #MyButton
  #firstname
  #lastname
  #Phone
EndEnumeration

Declare SetStringGadgetPlaceholder(Gadget, Placeholder.s)

OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 200, "Enter address", #PB_Window_ScreenCentered)

ButtonGadget(#MyButton, 10, 100, 80, 22, "ClickMe") ;Intruder !!

StringGadget(#firstname, 10, 10, 200, 20, "")
SetStringGadgetPlaceholder(0, "First name")

StringGadget(#lastname, 10, 40, 200, 20, "")
SetStringGadgetPlaceholder(1, "Last name")

StringGadget(#Phone, 10, 70, 200, 20, "")
SetStringGadgetPlaceholder(#phone, "Phone number")

Procedure SetStringGadgetPlaceholder(Gadget, Placeholder.s)
  !$('#dijit_form_TextBox_' + v_gadget).attr('placeholder', v_placeholder);
EndProcedure

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
Fred
Site Admin
 
Posts: 1162
Joined: Mon Feb 24, 2014 10:51 am

Re: Set Placeholder-Attribute for StringGadget

by Fred Wed Jun 01, 2016 4:20 pm

You should use Peter's way, it's the better way to get the input from a stringgadget:

Code: Select all
Procedure.i GadgetElement(Gadget, UseJquery.b=#True)
  ; by eddy (http://forums.spiderbasic.com/viewtopic.php?p=320#p320)
  Protected gadgetObject=GadgetID(Gadget)
  !return (v_gadgetobject && v_gadgetobject.div)? v_usejquery? $(v_gadgetobject.div):v_gadgetobject.div:null;
EndProcedure

Procedure SetStringGadgetPlaceholder(StringGadget, Placeholder.s)
  Protected SG = GadgetElement(StringGadget)
  !v_sg.find("input").attr("placeholder", v_placeholder);
EndProcedure

OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 200, "Enter address", #PB_Window_ScreenCentered)

StringGadget(0, 10, 10, 200, 20, "")
SetStringGadgetPlaceholder(0, "First name")

StringGadget(1, 10, 40, 200, 20, "")
SetStringGadgetPlaceholder(1, "Last name")

StringGadget(2, 10, 70, 200, 20, "")
SetStringGadgetPlaceholder(2, "Phone number")
User avatar
SparrowhawkMMU
 
Posts: 277
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Set Placeholder-Attribute for StringGadget

by SparrowhawkMMU Thu Jun 02, 2016 10:50 am

Peter, nice tip - I had not see this thread before. I'll use the above in my own apps now :)

Fred, are you planning to wrap this up into a built-in SB function?
Fred
Site Admin
 
Posts: 1162
Joined: Mon Feb 24, 2014 10:51 am

Re: Set Placeholder-Attribute for StringGadget

by Fred Thu Jun 02, 2016 11:19 am

Could be
User avatar
SparrowhawkMMU
 
Posts: 277
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Set Placeholder-Attribute for StringGadget

by SparrowhawkMMU Thu Jun 02, 2016 1:14 pm

:D Nicely non-committal!
Fred
Site Admin
 
Posts: 1162
Joined: Mon Feb 24, 2014 10:51 am

Re: Set Placeholder-Attribute for StringGadget

by Fred Thu Jun 02, 2016 3:02 pm

:lol:
Dirk Geppert
 
Posts: 132
Joined: Fri Sep 22, 2017 7:02 am

Re: Set Placeholder-Attribute for StringGadget

by Dirk Geppert Wed Oct 24, 2018 12:49 pm

Since the parameter #PB_String_PlaceHolder is now available for the string gadget. How can I add a placeholder to the EditorGadget?

Ciao Dirk
User avatar
RSBasic
 
Posts: 36
Joined: Mon Oct 15, 2018 1:17 pm
Location: Berlin

Re: Set Placeholder-Attribute for StringGadget

by RSBasic Thu Oct 25, 2018 7:35 am

ImageImageImageImageImage
Return to Tricks 'n' Tips

Who is online

Users browsing this forum: No registered users and 2 guests