FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour Dialog or Form
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Dialog or Form
Posted: Sat Jun 11, 2022 08:00 PM
Hello Adhemar, hello Shuming,

https://mybergland.com/fwforum/mh_dbf.zip

I have a very simple mod harbour example here.


Call: with index?recno= opens a stored record
only index.prg creates a new record.

For a newcomer, this example is ideal.
If you have any questions, please contact me.

Best regards,
Otto

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Dialog or Form
Posted: Sun Jun 12, 2022 12:54 PM
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Dialog or Form
Posted: Sun Jun 12, 2022 07:06 PM

Now we trigger the event on the anchor tag elements <a></a>

https://mybergland.com/fwforum/bootstra ... igger.html

Download

https://mybergland.com/fwforum/mh_dbf_nav_click.zip

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Dialog or Form
Posted: Mon Jun 13, 2022 08:12 PM
Hello friends,

Now with 2 lines of code and a universal function of Mr. Rao you can browse every dbf file.
Best regards,
Otto

https://mybergland.com/fwforum/mh_dbf_browse.zip




Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Dialog or Form
Posted: Thu Oct 27, 2022 03:49 PM
Dear Otto,

maybe you would be so kind as to share a simple sample of a form including an <input type="file"> field for image upload too?

I tried to fill the VALUE of <input type="file" > with the value from the database and take this suggestion in case nothing is selected by the user

but as stated here:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
You cannot set the value of a file picker from a script — doing something like the following has no effect:
Code (fw): Select all Collapse
const input = document.querySelector("input[type=file]");
input.value = "foo";
how can I prevent the code from overriding existing values in the database with an empty string everytime the user doesn´t select an image?

kind regards and many thanks in advance
Ruth
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Dialog or Form
Posted: Thu Oct 27, 2022 03:54 PM

...please allow me another question:

is it possible to next IF ENDIF logic inside of a CASE statement?

many thanks and kind regards

Ruth

Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Dialog or Form
Posted: Thu Oct 27, 2022 05:36 PM
Found the answer ...
I put this IF statement in the existing logic within a CASE and it worked :-)
Code (fw): Select all Collapse
   case FieldName( n ) == "PICTURE"
            if Empty( hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ))
            else 
            FieldPut( n, hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) )
            endif
Maybe someone can explain to me the difference between what does
Code (fw): Select all Collapse
  case FieldType( n ) == "L"
                  FieldPut( n, "on" $ hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) )
and at the end
Code (fw): Select all Collapse
   if FieldType( n ) == "L"
                        FieldPut( n, .F. )
                     endif
Here is the whole block:
Code (fw): Select all Collapse
 for n = 1 to FCount()
      if hb_HHasKey( hPost, FieldName( n ) )
            do case

            case FieldName( n ) == "PICTURE"
            if Empty( hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ))
            else 
            FieldPut( n, hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) )
            endif
            
            case FieldType( n ) == "D"
               FieldPut( n, CToD( hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) ) )
               
            case FieldType( n ) == "L"
                  FieldPut( n, "on" $ hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) )     
                  
            case FieldType( n ) == "N"
                     FieldPut( n, VAL( hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) ) )

             otherwise   

                      FieldPut( n, hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) )
                     
             endcase   
         else
                     if FieldType( n ) == "L"
                        FieldPut( n, .F. )
                     endif      
              
    endif 
  
  next
Kind regards again to all of you,
Ruth
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Dialog or Form
Posted: Fri Oct 28, 2022 08:32 AM
Ruth,

FieldType( n ) == "L"
Determines the data type for a field in the DBF file ( in this case logical )

https://harbour.github.io/doc/clct3.html#fieldtype



FieldPut( n, "on" $ hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) )

This is
if "on" is in your Hash than this is .t. otherwise .f.

"on" $ hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) )

hPost is the value in your FORM.

Best regards,
Otto
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: Dialog or Form
Posted: Fri Oct 28, 2022 03:52 PM
thank you very much :-)

Continue the discussion