Help Desk Software & Beyond
May 23, 2012, 05:59:54 AM *
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: [REQ] I want to set the "subject" to be the value of a custom field  (Read 2053 times)
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« on: July 18, 2008, 03:56:37 PM »

In my ticket submission form "newticket.html" i want the subject field to be equal to a custom field which is a dropdown list. Esentially I am making the subject field be a dropdown instead of typing so we can control what the subject is.
I entered this in my newticket.html file:
Code:
<input type=hidden name=subject value='(%INPUT_xCategory%)'>
The first time you hit submit it returns "Missing Subject" if I hit submit again it submits ok and works as expected.
How can I get this to work on the first submit? I'm going about this the wrong way and/or is there a better way?

I'd appreciate any help on this!
Thanks,
« Last Edit: July 18, 2008, 05:05:37 PM by Sparky » Logged
Sparky
Moderator
Hero Member
*****

Karma: 83
Posts: 2,228


stop pushing all those buttons


View Profile
« Reply #1 on: July 18, 2008, 05:05:20 PM »

This is logically flawed.  When it's submitted the first time, it has not yet any idea what you've chosen in your drop-down list.  After it give you the error and the page re-loads, the hidden field's value is set and it submits.

You'll have to instead set the value using Javascript.

We'll have to trigger the Javascript when the form is submitted.

Does this sound like a solution you want to pursue?
« Last Edit: July 18, 2008, 05:25:52 PM by Sparky » 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
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« Reply #2 on: July 19, 2008, 12:13:31 AM »

I really appreciate you looking into this!
Thanks
Logged
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« Reply #3 on: July 21, 2008, 09:58:03 AM »

Using the Javascript sounds fine to me unless there is a way to change the subject field to a dropdown list with predetermined items like you can do with the custom fields. This is way beyond my capabilities so any help you can give is appreciated!

Others might find this a helpful addon as I can't imagine my users are the only ones so creative as to write HELP!!!! or BROKE in the subject field.

Thanks again,
Logged
Sparky
Moderator
Hero Member
*****

Karma: 83
Posts: 2,228


stop pushing all those buttons


View Profile
« Reply #4 on: July 21, 2008, 10:28:58 AM »

Quote
...unless there is a way to change the subject field to a dropdown list with predetermined items like you can do with the custom fields.

Yes, that's an easier way to do it.

In your newticket.html template...

remove this:

Quote
<input type=text size=40 name=subject value="(%INPUT_subject%)">

Add this in its place:

Quote
<select name="subject">
<option value="">Please choose a subject...</option>
<option value="My Subject 1">My Subject 1</option>
<option value="My Subject 2">My Subject 2</option>
<option value="My Subject 3">My Subject 3</option>
<option value="My Subject 4">My Subject 4</option>
</select>

And finally add this to the very end of the file:

Code:
<script type="text/javascript"><!--
var i;
for (i = 0; i < document.forms['newticket'].subject.options.length; i++) {
  if (document.forms['newticket'].subject.options[i].text == '(%INPUT_subject%)') {
    document.forms['newticket'].subject.options[i].selected = true;
  }
}
//--></script>
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
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« Reply #5 on: July 21, 2008, 12:08:32 PM »

This worked perfectly.
Thank you very much!
Logged
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« Reply #6 on: August 19, 2008, 03:59:02 PM »

Sparky I am trying to do something else similar to this and not having much luck. I have a javascript that turns fields on when a item is selected from a dropdown field.
So in my template form I basically have a place holder:
Code:
<tr>
    <td align="right" class="lbl"><b id="unitlbl"></b></td>
     <td align=left><input type="hidden" name="unittext" id="unittext"></td>
</tr>
The javascript adds the text to the label and recreates the input box as type=text
All works great but....
Now I want the value of the box to be saved as one of my custom fields, lets say c3.
I would think this would do it by adding to end of file similar to your previous suggestion.
Code:
<script type="text/javascript"><!--
 (document.forms['newticket'].unittext.value == '(%INPUT_c3%)')
//--></script>

Hope you can help!
Thanks
Logged
Sparky
Moderator
Hero Member
*****

Karma: 83
Posts: 2,228


stop pushing all those buttons


View Profile
« Reply #7 on: August 19, 2008, 04:19:15 PM »

Quote
<tr>
    <td align="right" class="lbl"><b id="unitlbl"></b></td>
     <td align=left><input type="hidden" name="unittext" id="unittext"></td>
</tr>

Quote
<script type="text/javascript"><!--
 (document.forms['newticket'].unittext.value == '(%INPUT_c3%)')
//--></script>

More than a couple of problems.

1.  This is incomplete...

<input type="hidden" name="unittext" id="unittext">

There is no point to a hidden field if there's no value.  There should be a value="" included inside.  However this won't solve your problem anyway and I don't think you need a hidden field to do your mod.


2.  This won't do anything for two reasons...

(document.forms['newticket'].unittext.value == '(%INPUT_c3%)')

a.  %INPUT_c3% is a macro that gets filled in from the URL query string.  Unless you bring in your c3 value via the URL, this will always be blank.

b.  Incorrect syntax.  A double equal sign is used for conditionals.  IF a == b, THEN c.  If you want to set something to something else, just a single equal sign will do.



To make an input field for c3, you need to NAME it "xunittext".  The "value" is the part that the user fills in.

Short of writing this code for you, all I can say is that you're running down the wrong track... but you're learning.

Manually write the code for the input field, xunittext, and then figure out how to toggle its visibility.  There are several ways using CSS controlled by Javascript.
« Last Edit: August 19, 2008, 04:44:49 PM by Sparky » 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
Paul Nolette
Newbie
*

Karma: 10
Posts: 49


View Profile
« Reply #8 on: August 19, 2008, 05:03:46 PM »

I took what you said and re-read some of Alex's custom field how-to's and I think I got what i'm looking for.
this is what I put in the template:
Code:
<tr>
    <td align="right" class="lbl"><b id="unitlbl"></b></td>
    <td align=left><input type="hidden" name=xUnit value="(%INPUT_xUnit%)" id="unittext"></td>
</tr>

Now the javascript puts the text in the lbl with:
Code:
frmObj.all.unitlbl.innerHTML = "Unit #";

and re-creates the input field with:
Code:
changeInputType(frmObj.all.unittext, "hidden");
which calls
Code:
function changeInputType(oldObject, oType) {
  var newObject = document.createElement('input');
  newObject.type = oType;
  if(oldObject.size) newObject.size = oldObject.size;
  if(oldObject.value) newObject.value = oldObject.value;
  if(oldObject.name) newObject.name = oldObject.name;
  if(oldObject.id) newObject.id = oldObject.id;
  if(oldObject.className) newObject.className = oldObject.className;
  oldObject.parentNode.replaceChild(newObject,oldObject);
  return newObject;
}

So i esentially have hidden labels and text fields which get "turned on" by the javascript.
Not sure if it's the best way but it works well!

Thanks for your input as always!
Logged
rozwellite
Newbie
*

Karma: 2
Posts: 43



View Profile
« Reply #9 on: September 09, 2011, 05:36:54 PM »

I also wanted a drop down box for the subject. I went ahead and changed the newticket.html but I found that when I go to edit the other tickets where customers have choose the wrong items. I dont have the drop down. Can you please tell me what I need to edit to give me the drop downs when I click on the ticket number? Thank you.
Logged
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.028 seconds with 18 queries.