<本体>"/> select<本体>">

ホームページ >バックエンド開発 >PHPチュートリアル >thinkphp はタグ ライブラリを修正して書き込み、エディターを使用します

thinkphp はタグ ライブラリを修正して書き込み、エディターを使用します

WBOY
WBOYオリジナル
2016-06-13 12:22:39958ブラウズ

thinkphp はタグ ライブラリを変更して書き込み、エディタを使用します
ビュー ディレクトリに Index_aaa.html を作成します

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="dec"><!DOCTYPE html></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="tag"><head></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="tag"><meta</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"UTF-8"</span><span class="tag">></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="tag"><title></span><span class="pln">select</span><span class="tag"></title></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="tag"></head></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="tag"><body></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="tag"><html:select</span><span class="pln"> </span><span class="atn">options</span><span class="pun">=</span><span class="atv">"address"</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"sh"</span><span class="pln">  </span><span class="atn">values</span><span class="pun">=</span><span class="atv">"address"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"></body></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"></html></span></code></li></ol>

IndexController.class.php に関数を書き込みます

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> aaa</span><span class="pun">(){</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"address"</span><span class="pun">,[</span><span class="str">"sh"</span><span class="pun">=></span><span class="pln"> </span><span class="str">"上海"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">,</span><span class="str">"北京"</span><span class="pun">,</span><span class="str">"郑州"</span><span class="pun">]);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">display</span><span class="pun">();</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>


このファイルを変更してタグ ライブラリを作成します


values='0'

の問題を解決するために出力項目をすべてvalに変更し、valuesの値をオプションの値と等しくします


新しいタグを作成します

'ms'=>array('attr'=> ;'id,name, options,selected','close'=>0)

2ce148bf213872dc3e2a525c123f4fab639719422afbc0b1f22f00b5d953358a

改造コード選択 値は任意に記述可能


<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">  </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _ms</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $name       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $options    </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $id         </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        $selected   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span><span class="pln">      </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php if("'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'"==$val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

選択した値に応じて決定可能

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _ms</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $name       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $options    </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        $id         </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        $selected   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span><span class="pln">      </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">          </span><span class="com">/*  $parseStr .='<?php if("'.$selected.'"==$val) { ?>';*///selected的值可以随便写</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php if($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'==$val) { ?>'</span><span class="pun">;</span><span class="com">//值可以先分配再写</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> aaa</span><span class="pun">(){</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"address"</span><span class="pun">,[</span><span class="str">"上海"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">,</span><span class="str">"北京"</span><span class="pun">,</span><span class="str">"郑州"</span><span class="pun">]);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"sh"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">display</span><span class="pun">();</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html:ms</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"aa"</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"uu"</span><span class="pln"> </span><span class="atn">options</span><span class="pun">=</span><span class="atv">"address"</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"sh"</span><span class="tag">/><br></span></code></li></ol>

フレームワーク自体でも実現できます


赤い線の $key を $val に変更することもできますが、システムには少し変更が加えられています。

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _select</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $name       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $options    </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $values     </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'values'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        $output     </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'output'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        $multiple   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'multiple'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">        $id         </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">        $size       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'size'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">        $first      </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'first'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">        $selected   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">        $style      </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'style'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $ondblclick </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'dblclick'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">		$onchange	</span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'change'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$multiple</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" ondblclick="'</span><span class="pun">.</span><span class="pln">$ondblclick</span><span class="pun">.</span><span class="str">'" onchange="'</span><span class="pun">.</span><span class="pln">$onchange</span><span class="pun">.</span><span class="str">'" multiple="multiple" class="'</span><span class="pun">.</span><span class="pln">$style</span><span class="pun">.</span><span class="str">'" size="'</span><span class="pun">.</span><span class="pln">$size</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">        </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">        	$parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" onchange="'</span><span class="pun">.</span><span class="pln">$onchange</span><span class="pun">.</span><span class="str">'" ondblclick="'</span><span class="pun">.</span><span class="pln">$ondblclick</span><span class="pun">.</span><span class="str">'" class="'</span><span class="pun">.</span><span class="pln">$style</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">        </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$first</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="" >'</span><span class="pun">.</span><span class="pln">$first</span><span class="pun">.</span><span class="str">'</option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$options</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php  foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $key=>$val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">            </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$selected</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php if(!empty($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && ($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">' == $val || in_array($key,$'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'))) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php }else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">            </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">            </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$values</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php  for($i=0;$i<count($'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">');$i++) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">            </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$selected</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php if(isset($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && ((is_string($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && $'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">' == $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i]) || (is_array($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && in_array($'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i],$'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">')))) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php }else { ?><option value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">            </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">            </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

を選択した後、ueditor を導入して js に配置し、ueditor.config.js を次のコードに変更します

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    window</span><span class="pun">.</span><span class="pln">UEDITOR_HOME_URL </span><span class="pun">=</span><span class="pln"> </span><span class="str">"/Public/js/ueditor/"</span><span class="pun">;</span><span class="pln">  </span></code></li></ol>



Baidu エディタを thinkphp に入れる

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    $parseStr   </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<script id="container" name="content" type="text/plain">这里写你的初始化内容</script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.config.js"></script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.all.js"></script><script type="text/javascript">        var ue = UE.getEditor("container",{emotionLocalization:true,lang:"zh-cn",initialFrameWidth:"80%",initialFrameHeight:320,textarea:"content",initialContent:"欢迎留言!",    autoClearinitialContent:true}); </script>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">            </span></code></li></ol>

次に Index_aaa.html に表示するコードを記述します

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html:editor</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"UEDITOR"</span><span class="tag">></html:editor></span></code></li></ol>







Wiz Notes (Wiz) より



声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
前の記事:SQL IN 関連の質問次の記事:SQL IN 関連の質問