Dialog or Form

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

Re: Dialog or Form

Postby Otto » Sat Jun 11, 2022 8: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

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dialog or Form

Postby Otto » Sun Jun 12, 2022 12:54 pm

********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dialog or Form

Postby Otto » Sun Jun 12, 2022 7:06 pm

********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dialog or Form

Postby Otto » Mon Jun 13, 2022 8: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

Image


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dialog or Form

Postby Ruth » Thu Oct 27, 2022 3: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: Select all  Expand view  RUN
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
User avatar
Ruth
 
Posts: 172
Joined: Fri Dec 07, 2007 1:26 pm

Re: Dialog or Form

Postby Ruth » Thu Oct 27, 2022 3: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
User avatar
Ruth
 
Posts: 172
Joined: Fri Dec 07, 2007 1:26 pm

Re: Dialog or Form

Postby Ruth » Thu Oct 27, 2022 5:36 pm

Found the answer ...
I put this IF statement in the existing logic within a CASE and it worked :-)

Code: Select all  Expand view  RUN
  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: Select all  Expand view  RUN
 case FieldType( n ) == "L"
                  FieldPut( n, "on" $ hb_UrlDecode( hb_HGet( hPost, FieldName( n ) ) ) )  

and at the end
Code: Select all  Expand view  RUN
  if FieldType( n ) == "L"
                        FieldPut( n, .F. )
                     endif      


Here is the whole block:

Code: Select all  Expand view  RUN
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
User avatar
Ruth
 
Posts: 172
Joined: Fri Dec 07, 2007 1:26 pm

Re: Dialog or Form

Postby Otto » Fri Oct 28, 2022 8: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: Dialog or Form

Postby Ruth » Fri Oct 28, 2022 3:52 pm

thank you very much :-)
User avatar
Ruth
 
Posts: 172
Joined: Fri Dec 07, 2007 1:26 pm

Previous

Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 3 guests

cron