Help Desk Software & Beyond
June 24, 2017, 06:50:46 PM *
Welcome, Guest. Please login or register.
To post messages you need to register. We apologize for inconvenience, but this is to prevent spam.
Registration is instant (no email verification) and we do not ask for any personal information.

Login with username, password and session length
News: Welcome to Help Desk Software forum!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [INFO] Hide Input Field and Submit Default Value  (Read 30931 times)
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« on: June 17, 2008, 08:00:52 PM »

TUTORIAL - Hide any New Ticket Input Field and Submit a Default Value

Commonly requested is how to remove an input field from the New Ticket form and instead submit a default value in its place.  It's been explained many times already but since everyones' setup is different, it would need to again.

With this tutorial, I will attempt to explain how you could figure this out.  Experience with basic HTML editing is required.

1.  Set up your New Ticket form with all the desired fields including the ones you'll be hiding later.  Either activate it in Setup, create it in Layout Designer, or manually with HTML.  Don't worry, we'll hide it later.  Wink

2.  Call up TTX in your browser and choose the New Ticket page.  Are all your input fields shown?  Good.  Now decide which input field you're going to hide.  This applies to any input field type... text box, text area, selection list, checkboxes, radio buttons.

3.  With your browser still on the New Ticket page, switch to HTML source code mode.  (Tip:  Firefox- View Menu -> Page Source)

4.  Find your input field in the HTML source code.  For this example, I'll choose something that anyone would have on a stock TTX installation with no options installed.  Let's remove the "Subject Line" text box.

Locate the HTML:

Quote
<input type=text size=40 name=subject value="">

This will be different depending on the field you wish to remove.  This is where a good working knowledge of HTML will come in handy.  You must be able to locate the HTML code for the field you're attempting to remove.

5.  Now that you've seen the HTML code for the field in action on the actual page, we can write the new hidden field code.  We're only figuring it out and writing it down for now... nothing to edit yet.

In our example, we only need to take the name= attribute from our original field... nothing else.

Quote
<input type="hidden" name="subject" value="I Need Help">

The value= attribute is what you want submitted to TTX with this hidden field.  For HTML compliance, I like enclosing all attribute values with a set of quotation marks.

6.  We'll have to figure out how to edit the newticket.html template.  Open this template in a plain text editor.  You'll need to remove the field, its label, and just to be safe, the entire table row.

Quote
<tr>
  <td align=right class=lbl>
[%Subject%]<font color=red><sup>*</sup></font></td>
  <td align=left><input type=text size=40 name=subject value="(%INPUT_subject%)"></td>
</tr>

7.  Now we need to insert the hidden input field we wrote before.  It must be contained between the <form> tags named newticket.  So find this line, and add your new hidden input field immediately below it.

Quote
<form method=post action="(%ENV_SCRIPT_NAME%)" name=newticket enctype="multipart/form-data" onsubmit="return onlyonce()">
<input type="hidden" name="subject" value="I Need Help">


That's it... your field is hidden from your customers and the correct value is always submitted to all new tickets.  In this example, there is no "subject" field on the form and all new tickets will have the same subject, "I Need Help".

Next post in this thread is more advanced.  I'll explain what to do if you're removing a field that is already part of a larger macro.
« Last Edit: June 18, 2008, 12:04:54 AM by sparky672 » Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
Sparky
Moderator
Hero Member
*****

Karma: 85
Posts: 2,275


stop pushing all those buttons


View Profile
« Reply #1 on: June 17, 2008, 11:52:35 PM »

ADVANCED - How to handle a Custom Input Field (Layout Designer)

What if the field you'd like to hide is a custom input field created with the Layout Designer?

In this example, I created a custom input field (c0) called "Priority" with values of low, medium, and high.

Step 4 from above yields the following code...

Quote
<tr><td align=right class=lbl>Priority</td>
<td align=left><select name="xPriority">
<option></option>
<option>low</option>
<option>medium</option>
<option>high</option>
</select></td></tr>



Now I'd like to remove the option from the customers' control and have all new tickets default to "medium" priority.

Let's continue...

5.  We can write the new hidden field code now.  We're only figuring it out and writing it down for now... nothing to edit yet.

In our example, we only need to take the name= attribute from our original field... nothing else.

Quote
<input type="hidden" name="xPriority" value="medium">

Set the value= attribute to the default you desire, in this case, "medium".

6.  We'll have to figure out how to edit the newticket.html template.  Open this template in a plain text editor.  Since all custom input fields are part of the (%CUSTOMVARS%) macro, there is apparently nothing to remove.  Really, you'll have to remove the (%CUSTOMVARS%) macro entirely.

7.  Since we just removed all custom input fields by removing that macro we'll now manually add back each custom input field as follows:

Quote
<input type="hidden" name="xPriority" value="medium">

Skip the row for custom field #0 since that's our hidden input field above.

Manually add a row for custom field #1...

Quote
<tr>
<td align="right" class="lbl">Label for custom field #1<font color="red"><sup>*</sup></font></td>
<td align="left">(%CUSTOM1%)</td>
</tr>

Manually add a row for custom field #2...

Quote
<tr>
<td align="right" class="lbl">Label for custom field #2<font color="red"><sup>*</sup></font></td>
<td align="left">(%CUSTOM2%)</td>
</tr>

Manually add a new row for each custom field by repeating code for each custom field, z...

Quote
<tr>
<td align="right" class="lbl">Label for custom field #z<font color="red"><sup>*</sup></font></td>
<td align="left">(%CUSTOMz%)</td>
</tr>

Optionally add red asterisks in red above as needed or desired.

Finally, add a line designating the mandatory custom fields.  Mandatory will mean that the form will give an error if the field is left blank by the customer.  Add them all to a single hidden field.  Do not add your original hidden field (xPriority) to this list since it will always be submitting the default value.

Quote
<input type="hidden" name="mandatory" value="xCustom1;xCustom2">


All fields that are part of other macros can also be handled in a similar fashion.
« Last Edit: June 18, 2008, 12:02:06 AM by sparky672 » Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC3 | SMF © 2001-2006, Lewis Media Valid XHTML 1.0! Valid CSS!
Page created in 0.022 seconds with 20 queries.