1

这是我的选择框的 html:

<select class=" reason_swap" id="call_type" name="call_type">
<option value=""></option>
<option title="OK - NO CHANGES" selected="" value="NC">OK - NO CHANGES</option>
<option title="OK - PENDING AUTH" value="PA">OK - PENDING AUTH</option>
<option title="OK - PENDING INS" value="IN">OK - PENDING INS</option>
<option title="OK - PENDING INS/PO" value="PI">OK - PENDING INS/PO</option>
<option title="OK - PENDING PO" value="PO">OK - PENDING PO</option></select>

我正在使用这个重新聚焦功能来强制这三个字段。

if ($this->call_type == 'NC' && $this->times_testing == '') $this->refocus('times_testing');
        if ($this->call_type == 'PA' && $this->times_testing == '') $this->refocus('times_testing');
        if ($this->call_type == 'IN' && $this->times_testing == '') $this->refocus('times_testing');

我遇到的唯一问题是我只是对如何抛出警报很挑剔,因为只有 5 个选项,如果五个选项中的三个不符合标准,我会发出警报,我只想这样做另一种方式...

如果不是 PI 或 PO,则提醒/重新关注 post

我想这会很简单..是这样的:

if (!$this->call_type == 'PI' && !$this->call_type == 'PO' && $this->times_testing == '') $this->refocus('times_testing');

但无济于事,它没有用。

任何帮助将不胜感激。谢谢你。

这是重新聚焦功能:

protected function refocus($name, $msg = '')
        {
        if (!$name) return;
        $this->halt = 1;
        $out = $msg ? $msg : _to_caps($name) . " is required...";
        $nest = $this->nest ? $this->nest . $name : $name; // no brackets on the name here since not allowed in HTML ids
        \Message::add("$out<input type='hidden' value='$nest' id='__refocus'>", 'not_ok');
        }
4

0 回答 0