NEW Add function ajax_autoselect

This commit is contained in:
Laurent Destailleur 2017-03-23 11:16:30 +01:00
parent 0a35d17207
commit 996cb9d3f1
3 changed files with 23 additions and 13 deletions

View File

@ -347,6 +347,25 @@ function ajax_dialog($title,$message,$w=350,$h=150)
return $msg;
}
/**
* Make a input box content all selected
*
* @param string $htmlname Id of html object
* @param int $addlink Add a link to after
*/
function ajax_autoselect($htmlname, $addlink=0)
{
global $langs;
$out = '<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#'.$htmlname.'").click(function() { jQuery(this).select(); } );
});
</script>';
if ($addlink) $out.=' <a href="'.$url.'" target="_blank">'.$langs->trans("Link").'</a>';
return $out;
}
/**
* Convert a html select field into an ajax combobox.
* Use ajax_combobox() only for small combo list! If not, use instead ajax_autocompleter().

View File

@ -338,18 +338,8 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php',1).'?sondage='.$object->id_sondage;
$urllink='<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">';
print $urllink;
if ($action != 'edit')
{
print '<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#opensurveyurl").click(function() { jQuery(this).select(); } );
});
</script>';
print ' <a href="'.$url.'" target="_blank">'.$langs->trans("Link").'</a>';
}
print '<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">';
if ($action != 'edit') print ajax_autoselect("opensurveyurl", 1);
print '</td></tr>';

View File

@ -209,7 +209,8 @@ function showPaypalPaymentUrl($type,$ref)
$out='<br><br>';
$out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>';
$url=getPaypalPaymentUrl(0,$type,$ref);
$out.='<input type="text" id="paypalurl" class="quatrevingtpercent" value="'.$url.'"><br>';
$out.='<input type="text" id="paypalurl" class="quatrevingtpercent" value="'.$url.'">';
$out.=ajax_autoselect("paypalurl", 0);
return $out;
}