Add graphic [?] button to custom fields?

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

Add graphic [?] button to custom fields?

Post by Raven »

Hi, I have added the following code to the end of each user input (Name, E-Mail, Message etc...)

Code: Select all

 <a href="Javascript:void(0)" onClick="Javascript:hesk_window('<?php echo HESK_PATH; ?>help_files/new_ticket_****.html','150','500')"><img src="<?php echo HESK_PATH; ?>img/help.png" alt="" width="11" height="11" border="0" align="absmiddle" style="vertical-align:middle" /></a>
This basically mimics how the help system works within the main settings of HESK but I have a .gif image as opposed to the standard [?].

This is working without any problems and I have had some very good feedback from my users. However, I also want to add this to the custom fields too - the problem is that when I do I get a syntax error :(

This is what I have in my custom field code so far

Code: Select all

	            /* Default text input */
	            default:
                	if (strlen($k_value) != 0)
                    {
                    	$v['value'] = $k_value;
                    }
					echo '
					<tr>
					<td valign="top" style="text-align:right" width="150"><p>'.$v['name'].': '.$v['req'].'</p></td>
					<td width="80%"><input type="text" name="'.$k.'" size="40" maxlength="'.$v['maxlen'].'" value="'.$v['value'].'" onblur="this.value = this.value.substr(0, 1).toUpperCase() + this.value.substr(1);" /> <?php echo HESK_PATH; ?>help_files/new_ticket_custom.html','150','500')"><img src="<?php echo HESK_PATH; ?>img/help.png" alt="" width="11" height="11" border="0" align="absmiddle" style="vertical-align:middle" /></a></td>
					</tr>
					';
	        }
	    }
	}
Any help with this would be awesome if any one knows how to make it work :)
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Instead of

Code: Select all

<?php echo HESK_PATH; ?>help_files/new_ticket_custom.html','150','500')">
try using something like

Code: Select all

<a href="Javascript:void(0)" onclick="Javascript:hesk_window('help_files/new_ticket_custom.html','150','500')">
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

Post by Raven »

Wooo, nearly there :)

I now have the following:

Code: Select all

	            /* Default text input */
	            default:
                	if (strlen($k_value) != 0)
                    {
                    	$v['value'] = $k_value;
                    }
					echo '
					<td valign="top" style="text-align:right" width="150"><p>'.$v['name'].': '.$v['req'].'</p></td>
             	    <td width="80%"><input type="text" name="'.$k.'" size="40" maxlength="'.$v['maxlen'].'" value="'.$v['value'].'" onblur="this.value = this.value.substr(0, 1).toUpperCase() + this.value.substr(1);" /> <a href="Javascript:void(0)" onclick="Javascript:hesk_window('help_files/new_ticket_custom.html','150','500')"><img src="<?php echo HESK_PATH; ?>img/help.png" alt="" width="11" height="11" border="0" align="absmiddle" style="vertical-align:middle" /></a></td>
					</tr>
					';
	        }
	    }
	}
But this gives me this error:
Parse error: parse error, expecting `','' or `';'' in C:\Webserver\Apache2.2\htdocs\Care+\index.php on line 310
I think it has to do with the <?php echo HESK_PATH; ?> part as I'm trying to define <?php while already within a php statement... I have also tried <img src="../img/help.png"... in an attempt to fix the above error but still got the same parse problem...

Any ideas?
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

You definitely need to remove/change the <?php echo HESK_PATH; ?> code for the reasons you mentioned. But the actual parse error shows because you need to escape the single quotes in the javascript code within the echo. So

Code: Select all

hesk_window('help_files/new_ticket_custom.html','150','500')">
should actually be

Code: Select all

hesk_window(\'help_files/new_ticket_custom.html\',\'150\',\'500\')">
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

Post by Raven »

Nice one this is now working :)

Just to clarify, I changed this:

Code: Select all

	            /* Default text input */
	            default:
                	if (strlen($k_value) != 0)
                    {
                    	$v['value'] = $k_value;
                    }
					echo '
					<tr>
					<td valign="top" style="text-align:right" width="150"><p>'.$v['name'].': '.$v['req'].'</p></td>
					<td width="80%"><input type="text" name="'.$k.'" size="40" maxlength="'.$v['maxlen'].'" value="'.$v['value'].'" onblur="this.value = this.value.substr(0, 1).toUpperCase() + this.value.substr(1);" /></td>
					</tr>
					';
	        }
	    }
	}
to this:

Code: Select all

	            /* Default text input */
	            default:
                	if (strlen($k_value) != 0)
                    {
                    	$v['value'] = $k_value;
                    }
					echo '
					<tr>
               		<td valign="top" style="text-align:right" width="150"><p>'.$v['name'].': '.$v['req'].'</p></td>
                    <td width="80%"><input type="text" name="'.$k.'" size="40" maxlength="'.$v['maxlen'].'" value="'.$v['value'].'" onblur="this.value = this.value.substr(0, 1).toUpperCase() + this.value.substr(1);" /> <a href="Javascript:void(0)" onclick="Javascript:hesk_window(\'help_files/new_ticket_custom.html\',\'150\',\'500\')"><img src="img/help.png" alt="" width="11" height="11" border="0" align="absmiddle" style="vertical-align:middle" /></a></td>
					</tr>
					';
	        }
	    }
	}
Now all I need to work out is how to have it show the name of the custom field in the help section as opposed to the hard coded 'Additional field' as it is at the moment lol
Post Reply