Page 1 of 1

Add graphic [?] button to custom fields?

Posted: Thu Oct 15, 2009 7:03 pm
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 :)

Posted: Fri Oct 16, 2009 1:23 pm
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')">

Posted: Fri Oct 16, 2009 3:01 pm
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?

Posted: Fri Oct 16, 2009 5:05 pm
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\')">

Posted: Sat Oct 17, 2009 6:57 pm
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