Page 1 of 1

Formatting of fields question

Posted: Wed Sep 05, 2007 4:09 pm
by Josh
Script URL: Internal
Version of script: .94
Hosting company: self
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:



I might know the answer already, but I'll ask anyway. Is there a way to format particular entries in the category field.

For example; Let's say a user is submitting a trouble ticket. Is it possible to have 3 of 15 categories listed in the drop down box a different color/underlined/bold/etc. It would be really helpful for us because of the way we've structured our categories. Asterisks are a decent way for a visual "cue", but something a little more obvious to the users would help them navigate the data entry page.

Thanks.

Posted: Wed Sep 05, 2007 4:55 pm
by Klemen
The options in a select box are very limited when it comes to formatting. The only thing I know of you can format for individual options is color by adding for example style="color:red" to the <option> tag:

Code: Select all

<option style="color:red">ONE</option>
<option>TWO</option>
<option style="color:green">THREE</option>
And to make THAT work you would have to edit category listings in index.php and mark with style those that match your requirements...

Posted: Wed Sep 05, 2007 6:04 pm
by Josh
That sounds like it would work. Could anyone give an example of the code for both option and category listings and help me figure out where to insert it?

I would only need one option. One color (other than black) should be fine. Is this similar to CSS, just attach a setting to the desired category?

Posted: Wed Sep 05, 2007 9:14 pm
by rbbigdog
I could be wrong here, but I think since the categories are being pulled directly from the database (through the index.php file), you're going have to recreate the option fields manually for each of your categories (using the Row ID for your value).

So this (in your Index.php):

<!-- Department and priority -->
<table border="0">
<tr>
<td align="right" width="150"><?php echo $hesklang['category']; ?>: <font class="important">*</font></td>
<td align="left" width="600"><select name="category">
<?php
require_once('inc/database.inc.php');

hesk_dbConnect() or hesk_error("$hesklang[cant_connect_db] $hesklang[contact_webmsater] $hesk_settings[webmaster_mail]!");
$sql = "SELECT * FROM `hesk_categories` ORDER BY `cat_order` ASC";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
while ($row=hesk_dbFetchAssoc($result))
{
if ($_SESSION['c_category'] == $row['id']) {$selected = ' selected';}
else {$selected = '';}
echo '<option value="'.$row['id'].'"'.$selected.'>'.$row['name'].'</option>';
}

?>
</select></td>
</tr>


Would end up looking something like this afterwards (depending on your Row ID's and category names):

<!-- Department and priority -->
<table border="0">
<tr>
<td align="right" width="150"><?php echo $hesklang['category']; ?>: <font class="important">*</font></td>
<td align="left" width="600"><select name="category">
<option style="color:green" value="1">Hardware</option>
<option style="color:green" value="2">Software</option>
<option value="3">Whatever1</option>
<option value="4">Whatever2</option>
<option value="5">Whatever3</option>
<option value="6">Whatever4</option>
</select>
</td>
</tr>


The biggest deal would be to get the correct ROW ID's for each of your categories. Again, that's just a guess and my syntax could be completely wrong here (since I haven't tried or tested it), but I think this is the direction you would need to go. Make sure you backup any files before you change them.

RB

Posted: Wed Sep 05, 2007 10:01 pm
by Josh
Ahhh, I think I am following the logic now. Create "entries" on the index page that have the attributes you want (in this case color) to replace the listings directly coming from that database.

The new code if correct should submit the required value to the database.


*Update: I just used the code and it seems to work well. I tried the option to change color, but I found if I just commented out the options I didn't want users to see that worked even better!


Just as background;


We have categories that users need to submit tickets to. Once tickets are submitted, they are assigned to specific people in our office (which are also classified as categories).

This way one IT user (who assigns the tickets to others) is assigned to see the same categories that users see. From there, she assigns the tickets to the correct person (category) to fix the problem. Each IT user can only see tickets assigned to their personal category.

It makes sense to those of us in the back office, but I think the extra options would totally confuse our users when trying to create a ticket. Hiding the extra categories is a pretty good fix if anyone else has tried to use a similar set up.

I guess the only caveat for anyone interested is that you can't change any categories through the admin panel without updating the index.php code.

Thanks so much for your help Klemen and rbbigdog.

Posted: Wed Sep 05, 2007 10:04 pm
by Josh
Here's what my code ended up like.

<!-- Department and priority -->
<table border="0">
<tr>
<td align="right" width="150"><?php echo $hesklang['category']; ?>: <font class="important">*</font></td>
<td align="left" width="600"><select name="category">
<option value="1">"Main Application"</option>
<option value="2">Phones</option>
<option value="3">Software</option>
<option value="4">Hardware</option>
<option value="5">Printer</option>
<option value="6">Reports</option>
<option value="7">New Hire</option>
<option value="8">Change/Move Request</option>
<option value="9">Other/Misc</option>
<!--<option style="color:green" value="10">*IS USE ONLY*</option>
<option style="color:green" value="11">*IS USE ONLY*</option>
<option style="color:green" value="12">*IS USE ONLY*</option>
<option style="color:green" value="13">*IS USE ONLY*</option>
<option style="color:green" value="14">*IS USE ONLY*</option>
<option style="color:green" value="15">*IS USE ONLY*</option>
<option style="color:green" value="16">*IS USE ONLY*</option>
<option style="color:green" value="17">*IS USE ONLY*</option>-->
</select>
</td>
</tr>

Posted: Thu Sep 06, 2007 2:11 am
by rbbigdog
It was Klemen who suggested it....I just tried to help a little with the html coding.

Glad it's working for you!

RB

Posted: Thu Sep 06, 2007 10:22 am
by Klemen
Don't be too modest rbbigdog, you helped a lot, also in some other posts :wink: