diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 82a6dadcfb86c704cf5f0b9d30d2aeba4b6f2471..824d326883d511e4eaeee0759025388e2b00845a 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -48,8 +48,9 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
 					var options = '.json_encode($ajaxoptions).';
 
 					// Remove product id before select another product
-					$("input#search_'.$htmlname.'").change(function() {
-						$("#'.$htmlname.'").val("").trigger("change");
+					// use keyup instead change to avoid loosing the product id
+					$("input#search_'.$htmlname.'").keyup(function() {
+							$("#'.$htmlname.'").val("").trigger("change");
 					});
 					// Check when keyup
 					$("input#search_'.$htmlname.'").onDelayedKeyup({ handler: function() {
@@ -163,7 +164,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
 					}).data( "autocomplete" )._renderItem = function( ul, item ) {
 						return $( "<li></li>" )
 						.data( "item.autocomplete", item )
-						.append( \'<a href="#"><span class="tag">\' + item.label + "</span></a>" )
+						.append( \'<a><span class="tag">\' + item.label + "</span></a>" )
 						.appendTo(ul);
 					};
   				});';
diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php
index 17da725a80d96d2aebf823b5332cd70938161fcd..5b6117681191349ebacb5e12d50aa51926d0f916 100644
--- a/htdocs/core/tpl/freeproductline_create.tpl.php
+++ b/htdocs/core/tpl/freeproductline_create.tpl.php
@@ -1,7 +1,7 @@
 <?php
-/* Copyright (C) 2010-2011 Regis Houssin       <regis@dolibarr.fr>
- * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2012      Christophe Battarel  <christophe.battarel@altairis.fr>
+/* Copyright (C) 2010-2012	Regis Houssin		<regis@dolibarr.fr>
+ * Copyright (C) 2010-2011	Laurent Destailleur	<eldy@users.sourceforge.net>
+ * Copyright (C) 2012		Christophe Battarel	<christophe.battarel@altairis.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -50,13 +50,10 @@
 	<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
 </tr>
 
-<form name="addproduct" id="addproduct"
-	action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id; ?>#add"
-	method="POST">
-	<input type="hidden" name="token"
-		value="<?php echo $_SESSION['newtoken']; ?>" /> <input type="hidden"
-		name="action" value="addline" /> <input type="hidden" name="id"
-		value="<?php echo $this->id; ?>" />
+<form name="addproduct" id="addproduct"	action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id; ?>#add" method="POST">
+<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
+<input type="hidden" name="action" value="addline" />
+<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
 
 	<tr <?php echo $bcnd[$var]; ?>>
 		<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
@@ -77,8 +74,9 @@
 			// Editor wysiwyg
 			require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
 			$nbrows=ROWS_2;
+			$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
 			if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
-			$doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
+			$doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,70);
 			$doleditor->Create();
 			?>
 		</td>
diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php
index a3dc4f412dc59c5e9a75b2aa92cc5d69aa3239b2..601f463682df20f20191c3e0fcb4a43d4ff6990c 100644
--- a/htdocs/core/tpl/predefinedproductline_create.tpl.php
+++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php
@@ -78,7 +78,7 @@ jQuery(document).ready(function() {
 
 	if (is_object($hookmanager))
 	{
-        $parameters=array('fk_parent_line'=>$_POST["fk_parent_line"]);
+        $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int'));
 	    $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
 	}
 
@@ -87,8 +87,9 @@ jQuery(document).ready(function() {
 	// Editor wysiwyg
 	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
     $nbrows=ROWS_2;
+    $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
     if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
-    $doleditor=new DolEditor('np_desc',$_POST["np_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
+    $doleditor=new DolEditor('np_desc',GETPOST('np_desc"'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,70);
 	$doleditor->Create();
 	?>
 	</td>
@@ -99,9 +100,9 @@ $colspan = 4;
 if (! empty($conf->margin->enabled)) {
 ?>
 	<td align="right">
-  <select id="fournprice" name="fournprice" style="display: none;"></select>
-  <input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
-  </td>
+		<select id="fournprice" name="fournprice" style="display: none;"></select>
+		<input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
+	</td>
 <?php
   if (! empty($conf->global->DISPLAY_MARGIN_RATES))
     $colspan++;
@@ -109,7 +110,9 @@ if (! empty($conf->margin->enabled)) {
     $colspan++;
 }
 ?>
-	<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>" name="addline"></td>
+	<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
+		<input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>" name="addline">
+	</td>
 </tr>
 
 <?php if (! empty($conf->service->enabled) && $dateSelector) {