NetTalk Central

Author Topic: Change color on a field on a form  (Read 1873 times)

McTim

  • Newbie
  • *
  • Posts: 2
    • View Profile
Change color on a field on a form
« on: March 01, 2012, 04:46:38 PM »
I have a netwebform with an entry field and a readonly field.  Upon completion of the entry field, I call a procedure which does many things and returns a value.  I display this value in a readonly field o nthe same form.   I would like to change the color of the readonly field based on data within the result from my other procedure.   How do I go about this?   

BTW, using Nettalk 4  Clarion 8

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: Change color on a field on a form
« Reply #1 on: March 01, 2012, 09:27:51 PM »
you would create a condition to set the css of the read-only field.
View the generated source of the procedure, you want to be embedding in the Value::fieldname routine (where fieldname is the use equate of the read-only field.)

you'll see the class is set there (I don't remember NT4, but in NT6 it's "loc:class".

you would want to create a bunch of classes, in your own css file, setting the background-color property.

Then you can set loc:class here to the css class you want.

Unfortunately I don't remember all the specifics of NT4 so I can't be a lot more specific.

cheers
Bruce

McTim

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Change color on a field on a form
« Reply #2 on: March 02, 2012, 09:47:09 AM »
Bruce -
  Here is that routine cut from the generated source.  I'm not sure if I have an embed point available.  I have figured out that for now, I should be able to set it to Required (which will turn it RED) when it meets my condition but, not sure where/how to do this.

  My condition is basically 
      if result[1:2] = 'N,'
         !set color to RED
      else
         ! set color to green
      end

Thanks

Value::Result  Routine
  ! Start of "Set Value"
  ! [Priority 5000]
 
  ! End of "Set Value"
  p_web._DivHeader('GetTicketNumber2_' & p_web._nocolon('Result') & '_value','adiv')
  ! Start of "Set Value"
  ! [Priority 5000]
 
  ! End of "Set Value"
  loc:extra = ''
  ! --- STRING --- Result
    loc:AutoComplete = 'autocomplete="off"'
  loc:readonly = 'readonly'
  loc:fieldclass = 'FormEntry'
  loc:fieldclass = clip(loc:fieldclass) & ' ' & 'formreadonly'
  If lower(loc:invalid) = lower('Result')
    loc:fieldclass = clip(loc:fieldclass) & ' ' & 'formerror'
  End
    loc:extra = clip(loc:extra) & ' size="' & clip(100) &'"'
  loc:javascript = ''
  loc:javascript = clip(loc:javascript) & ' onchange="'&p_web._nocolon('sv(''Result'',''getticketnumber2_result_value'',1,FieldValue(this,1))')&';'
  loc:javascript = clip(loc:javascript) & 'nextFocus('&clip(loc:formname)&','''&p_web._nocolon('Result')&''',0);'
  if loc:javascript <> '' then loc:javascript = clip(loc:javascript) & '"'.
  packet = clip(packet) & p_web.CreateInput('text','Result',p_web.GetSessionValue('Result'),loc:fieldclass,loc:readonly,clip(loc:extra) & ' ' & clip(loc:autocomplete),'@s100',loc:javascript,100,) & '<13,10>'
  do SendPacket
  ! Start of "After Value"
  ! [Priority 5000]
 
  ! End of "After Value"
  p_web._DivFooter()
  p_web._RegisterDivEx('GetTicketNumber2_' & p_web._nocolon('Result') & '_value')


Rob de Jager

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: Change color on a field on a form
« Reply #3 on: March 02, 2012, 12:32:42 PM »
Enter a local variable in the required condition i.e. loc:conditionvar
In the source  --- >

Value::Result  Routine
  ! Start of "Set Value"
  ! [Priority 5000]

------------------Place your condition here and set loc:conditionvar to true or false for required or not.   

  ! End of "Set Value"
  p_web._DivHeader('GetTicketNumber2_' & p_web._nocolon('Result') & '_value','adiv')
  ! Start of "Set Value"
  ! [Priority 5000]
 
  ! End of "Set Value"
  loc:extra = ''
  ! --- STRING --- Result
    loc:AutoComplete = 'autocomplete="off"'
  loc:readonly =Choose(loc:conditionvar,'readonly','')
  loc:fieldclass = 'FormEntry'
  If loc:conditionvar
    loc:fieldclass = clip(loc:fieldclass) & ' ' & 'formreadonly'
  End
  loc:fieldclass = clip(loc:fieldclass) & ' ' & 'formreadonly'
  If lower(loc:invalid) = lower('Result')
    loc:fieldclass = clip(loc:fieldclass) & ' ' & 'formerror'
  End

Cheers


Rob