How to make checkbox array?

Sometimes while designing any form, we required to give multiple options to user. At that time our mind immediately say, put checkboxes and give multiple selections to user.

But while working with any server side scripting, our form and all its controls are submitted. So we must have to give proper name to each control.

Now if we are using multiple checkboxes to get multiple selections of same type of data, then it is difficult to give different names to each and every checkbox control.

At that time we can make group of checkboxes as a checkbox array, where all the checkboxes are related.

In which we just required to give common name to each checkbox with rectangular brackets [].

So now each checkbox is an element of checkbox array.

For example: Here we are making checkbox array to select multiple colors.


<input type="checkbox" name="colors[]" value="Red" /> Red

<input type="checkbox" name="colors[]" value="Green" /> Green

<input type="checkbox" name="colors[]" value="Blue" /> Blue

Hope this will help you.

Oscommerce, Solve UPS Error – “Call to undefined function tep_cfg_select_multioption()”

Before three days we have got “Fatal error: Call to undefined function tep_cfg_select_multioption() in /admin/modules.php(221) : eval()’d code on line 1” error while trying to edit the United Parcel Service (UPS) module configuration from our site admin.

And we have got solution of that, so we are sharing that solution.

Here the first question is: why this error has occurred? And what is the solution of it?

Here the error is saying “Call to undefined function tep_cfg_select_multioption()”, it means PHP doesn’t know anything about “tep_cfg_select_multioption()” function.

And this was happened because we didn’t add “tep_cfg_select_multioption()” function in “/admin/includes/functions/general.php” file.

Now to solve this problem just follow the under given two steps.

Step-1:

Add the following code to /admin/includes/functions/general.php, at the end just before the final “?>”:

// Alias function for array of configuration values in the Administration Tool
function tep_cfg_select_multioption($select_array, $key_value, $key = '') {
for ($i=0; $i<sizeof($select_array); $i++) {
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
$key_values = explode( ", ", $key_value);
if ( in_array($select_array[$i], $key_values) ) $string .= 'CHECKED';
$string .= '> ' . $select_array[$i];
}
return $string;
}
//

Step-2:

In /admin/modules.php, around line 37 replace:

case 'save':
while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
}

With

case 'save':
while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
if( is_array( $value ) ) $value = implode( ", ", $value);
tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
}

That’s it.

Hope this will help you.

Importing a layered Photoshop file (.PSD) into Flash CS3

Here, you can look at how Flash handles layered Photoshop files (PSD). I will show you all the process step by step to import PSD into Flash CS3.

First you have to examine as image in Photoshop and check some preferences, and then you can import the PSD file into Flash.

First we see that how to set preferences in Flash CS3.

1)      Open Flash -> Add New file (Action Script 3 or 2)

2)      Now, Edit menu, click on Preferences or Ctrl + U

3)      In Preferences Pop up window, Click PSD file Importer so here you can customize your option when you import PSD file, finally click OK


Now we see the steps for importing PSD file

1)      Select file menu, click on import and select Import to Stage or press Ctrl+R

It open pop window for importing PSD file, select your PSD file path to import.

After selecting path, your layered psd file import layers by layers

You can see all layers of your PSD. When you are importing, you have to insert instance name for your layers for future use, and last click on OK.

So now you can see in flash, PSD image should be arranged with layers by layers.

How to import images in Adobe Flash CS3?

We can import different image files in flash like .jpg and .gif. Most of these files are bitmap images and they have large size.

Whatever we are drawing in flash are vector images. Vector images are smaller in size and they can be enlarged without losing quality.

While bitmap images will stretched when enlarged.

In Adobe Flash CS3 we can import the image from File Menu -> Import -> Import to Stage / Import Library option.