change textfield to list menu change textfield to list menu
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

change textfield to list menu

Started by deanhat, April 04, 2010, 03:01:01 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

deanhat

Good Day !
Im quite sure this is a small change that needs to be made I just cant find the file(hopefully not files) to edit .
I would like to change the area (Custom fields for image description) where when you upload a file and have to add image descriptions , from a text field to a list menu . as an example I would like to make this change to the form so that when you upload a picture you have a drop down list of all the countries and you could choose the country the picture was taken ,,  if any one could help me i would be very happy :-)

Joachim Müller

You should start by respecting board rules... You've been told so when you signed up and when you composed your posting.

deanhat

sencere appologies . im using a localhost "xampp" for testing and the site that it will be deployed will be www.bloggersplace.com. here is also a snapshot of the screen that i would like the text field in to change to a list menu . 

deanhat

we i cant figure this out ,, mybe someone can help me with a script that brings up n sort of popup  menu with choices to insert  into the text field .. :-\ or does any one know where i would be able to insert my own form into the upload.php to display only my form, as a simple up loader

Αndré

You have to edit upload.php. Find
$form_array[] = array($CONFIG['user_field1_name'], 'user1', 0, 255, 1);
to
$form_array[] = array($CONFIG['user_field1_name'], 'user1', 5, 255, 1);

Then find
            // Based on the type declared in the data array's third position, create a different form input.
            switch ($element[2]) {

                // If the type is a text box input
                case 0 :

                    //Call the form input function.
                    text_box_input($element[0], $element[1], $element[3], $element[4], (isset($element[5])) ? $element[5] : '');
                    break;

                // If the type is a file input.
                case 1 :

                    // Call the file input function.
                    file_input($element[0], $element[1], $element[3]);
                    break;

                // If the type is an album list dropdown.
                case 2 :

                    // Call the album list function.
                    form_alb_list_box($element[0], $element[1]);
                    break;

                // If the type is a text area
                case 3 :

                    // Call the text area function.
                    text_area_input($element[0], $element[1], $element[3], (isset($element[4])) ? $element[4] : '');
                    break;

                // If the type is a hidden form
                case 4 :

                    // Call the hidden input funtion.
                    hidden_input($element[0], $element[1]);
                    break;

                // If the type is not present, kill the script.
                default:
                    cpg_die(ERROR, $lang_upload_php['reg_instr_1'], __FILE__, __LINE__);
            } // switch
        }

and add a new case 5, where you create your drop down box.

deanhat

Whoo thank you it works ;D ! I will make a guide for this as-well if any one else would like to do this ..

Αndré


Joachim Müller


deanhat


Joachim Müller

And what exactly is the benefit of the page you just refered to except the extra spelling mistakes that you added and the background that makes it harder to read? Looks like a copycat page to me - after all, Αndré has done all the work, and you don't even credit him or refer to the palce where you found piece of code.
You could at least have done as we suggest per board rules: Common policies: Resolve your threads

Αndré

The guide is a little more detailed and useful for people who don't know anything about HTML. As we have seen so much websites being not available after a while the real benefit would be to see that guide here in this thread.

deanhat

@Andre . i was meaning to put a special thanx to you and if you look at the page again you will see i added it ..
@Joachim thank you for yet again pionting out my mistakes .. this is how i learn , but i dont understand why you say it looks like a copycat page ? could you let me know why you think it is a copycat page ? if my spelling mistakes make it look less like a copycat page mybe ill make some more spelling mistakes next time .lol.

Joachim Müller


deanhat

I'm 999 years of age,, what does that have to do with anything on this script or thread .. if your revering to my sarcasm then I'm sorry for you if happy people get you upset .. .I am trying to contribute to your forum,, so at least try to make me feel welcome .

deanhat

Now the purpose of this guide is to make filling in info like location or a brand name etc.
lets start by opening the upload.php file
around about line 100 you will find the area where the functions start
we need to add the dropdown function so scroll down to where you want to add the code
I added it above

   
Quote// The hidden form input function. Takes the hidden input field name and value.
Now add the code :

 
Quote// Create the easyfill area.

    function easyfill ($text, $name)

    {

    echo <<<EOT

    <tr>

    <td class="tableb tableb_alternate" width="50">

    $text

    </td>

    <td class="tableb tableb_alternate" valign="top">

    <select >

    <option>example1</option>

    <option>example2</option>

    <option>example3</option>

    </select>

    </td>

    </tr>

    EOT;
    }
Perfect . next we will create a case for this function lets find the code

   
Quote// If the type is a hidden form

    case 4 :

    // Call the hidden input funtion.

    hidden_input($element[0], $element[1]);

    break;
just below that we will add the new case we have created , so just below the "break; add the next piece of code

   
Quote//creat a easy fill dropdown list case

    case 5 :

    easyfill($element[0], $element[1]);

    break;

Now all we need to do is to change the text fields current case to our new case 5

Go down and look for the code

   
Quoteif(!empty($CONFIG['user_field4_name'])) {

    $form_array[] = array($CONFIG['user_field4_name'], 'user4', 0, 255, 1);

    }

And change

'user4', 0, 255, 1);
to
'user4', 5, 255, 1);

So the code should now look like this

 
Quoteif(!empty($CONFIG['user_field4_name'])) {

    $form_array[] = array($CONFIG['user_field4_name'], 'user4', 5, 255, 1);

    }

Save your changes and provide easy fill to your users


Joachim Müller

Please remove unneeded double linebreaks and add indentation instead.