Skip to content
Snippets Groups Projects
Commit bd9003a8 authored by Regis Houssin's avatar Regis Houssin
Browse files

Try to add a help message in input fields

parent 0d13e62d
No related branches found
No related tags found
No related merge requests found
......@@ -227,8 +227,8 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans('DeliveryAddressLabel').'</td><td><input type="text" size="30" name="label" value="'.$livraison->label.'"></td></tr>';
print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" value="'.$livraison->nom.'"></td></tr>';
print '<tr><td>'.$langs->trans('DeliveryAddressLabel').'</td><td><input type="text" size="30" name="label" id="label" value="'.($livraison->label?$livraison->label:$langs->trans('RequiredField')).'" '.addHelpMessage("label",$langs->trans('RequiredField')).'></td></tr>';
print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" id="nom" value="'.($livraison->nom?$livraison->nom:$langs->trans('RequiredField')).'" '.addHelpMessage("nom",$langs->trans('RequiredField')).'></td></tr>';
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
print $livraison->adresse;
......
......@@ -543,6 +543,7 @@ FieldsWithIsForPublic=Fields with <b>%s</b> are shown on public list of members.
AccordingToGeoIPDatabase=(according to GeoIP convertion)
Line=Line
NotSupported=Not supported
RequiredField=Required field
# Week day
Day1=Monday
......
......@@ -542,6 +542,7 @@ FieldsWithIsForPublic=Les champs marqués par <b>%s</b> seront affiches sur la l
AccordingToGeoIPDatabase=(obtenu par conversion GeoIP)
Line=Ligne
NotSupported=Non supporté
RequiredField=Champ obligatoire
# Week day
Day1=Lundi
......
......@@ -3136,4 +3136,26 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
}
}
/**
* Return an help message in input field
* @param inputId Id of input field
* @param message Help message
* @return include Code to include if javascript is enable
*/
function addHelpMessage($inputId,$message)
{
global $conf;
$tempMessage = '';
if ($conf->use_javascript_ajax)
{
$tempMessage.= ' style="color: grey;"';
$tempMessage.= 'onFocus="hideMessage(\''.$inputId.'\',\''.$message.'\');" ';
$tempMessage.= 'onBlur="displayMessage(\''.$inputId.'\',\''.$message.'\');"';
}
return $tempMessage;
}
?>
\ No newline at end of file
// Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
// Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
// Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
//
// Script javascript added in header of pages (in HEAD section)
//
......@@ -65,7 +65,7 @@ function company_save_refresh()
Purpose: Pour la saisie des dates par calendrier
Input: base "/theme/eldy"
dateFieldID "dateo" Nom du champ
format "dd/MM/yyyy" Format issu de Dolibarr de SimpleDateFormat utiliser pour retour
format "dd/MM/yyyy" Format issu de Dolibarr de SimpleDateFormat utiliser pour retour
==================================================================*/
function showDP(base,dateFieldID,format)
......@@ -674,3 +674,31 @@ var win = new Window({className: "dialog",
win.getContent().update(message);
win.showCenter();
}
/*=================================================================
Purpose: Hide a temporary message in input text fields
Input: fiedId
Input: message
Author: Regis Houssin
Licence: GPL
==================================================================*/
function hideMessage(fieldId,message) {
var textbox = document.getElementById(fieldId);
textbox.style.color = 'black';
if (textbox.value == message) textbox.value = '';
}
/*=================================================================
Purpose: Display a temporary message in input text fields
Input: fieldId
Input: message
Author: Regis Houssin
Licence: GPL
==================================================================*/
function displayMessage(fieldId,message) {
var textbox = document.getElementById(fieldId);
if (textbox.value == '') {
textbox.style.color = 'grey';
textbox.value = message;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment