Jump to content
php.lv forumi

Ka izmainit saturu ?


Mikijs

Recommended Posts

Sveiki!

 

Nepiecieshams izveidot DIV prieksh katra Input

tatad ja man ir

<input type="text" name="kautkas" value="" class="...">

 

tad man vajadzetu kko sadu

<div id="pencilMode-0" class="hidden"></div>
<input type="text" onfocus="pencilMode('pencilMode-0','enable');" onblur="pencilMode('pencilMode-0','disable');" name="kautkas" value="" class="...">
<div id="pencilMode-1" class="hidden"></div>
<input type="text" onfocus="pencilMode('pencilMode-1','enable');" onblur="pencilMode('pencilMode-1','disable');" name="kautkas" value="" class="...">
<div id="pencilMode-2" class="hidden"></div>
<input type="text" onfocus="pencilMode('pencilMode-2','enable');" onblur="pencilMode('pencilMode-2','disable');" name="kautkas" value="" class="...">
<div id="pencilMode-3" class="hidden"></div>
<input type="text" onfocus="pencilMode('pencilMode-3','enable');" onblur="pencilMode('pencilMode-3','disable');" name="kautkas" value="" class="...">

 

esmu izveidojis kkadu tur kodu, jutu ka nekas nesanaks vismaz pagaidam nesanak, tatads kods

<?php
   function pencilMode($content){
     $html="";
     $pencilMode = "####PENCILMODE####";
     $old = "<input type=\"text\"";
     $new = "onfocus=\"pencilMode('pencilMode-".$prencilMode."','enable');\" onblur=\"pencilMode('pencilMode-".$prencilMode."','disable');\"";
     $new = "<dvi id=\"pencilMode-".$prencilMode."\" class=\"hidden\"></div>\n<input type=\"text\" ".$new;
     $new = str_replace($old,$new,$content);
     $max = explode("<dvi id=\"pencilMode-",$new);
     $mac = count($max);
     for($i=0;$i<=$mac;$i++) {
       $html.=str_replace($pencilMode,$i,$new[$i]);
     }
     return $html;
   }
?>

 

zinu ka mulkigs skripts,bet nevelos labot katru templetia failu tikai lai izmainitu kaut kaduvertibu ieksh inputa . Paldies ja palidzat, ta pat ja ne.

 

 

 

m1k.

Edited by Mikijs
Link to comment
Share on other sites

tas bija paraugs ko rakstiju ar roku, tas nozime ka koda stabili ir <div :)

 

tagad uztaisiju kko shadu

vopsem tikugala laikam.

 

<?php
function pencilMode($content) {
  $type='text';
  $str1=":R:E:P:L:A:C:E:";
  $str2=":::REPLACE:::";
  $get='<input type="'.$type.'"';
  $insert=$str1."<div id=\"pencilMode('pencilMode-$str2');\"></div>
  <input type=\"$type\" onfocus=\"pencilMode('pencilMode-$str2','enable');\" onblur=\"pencilMode('pencilMode-$str2','disable');\"";
  $new=str_replace($get,$insert,$content);
  $ex=explode($str1,$new);
  if(count($ex)){
	for($i=1;$i<=count($ex);$i++) {
	  $html.=str_replace($str2,$i,$ex[$i]);
	}
  }
  return $ex[0].$html;
}
?>

Link to comment
Share on other sites

×
×
  • Create New...