2012-11-27 08:10
浏览 50

用于下拉值问题的Javascript onchange

I have 2 frames of php files, first is call topFrame and bottom is called mainFrame. In the topFrame I have a php file with a dropdown value, onchange I would want to reload this frame with another php file.

Below is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script type="text/javascript">

function showsupli(sta)

alert ("sta");
if (sta == 'Yes')


echo "<form name='f1'>";

echo "<table width='730' border='0' align='center' cellpadding='0' cellspacing='1'>";
echo "  <tr>";
echo "    <td><span class='style3'>Suplimentry Invoice</span></td>";

echo "    <td>";
echo "<select name='supli' onchange=\"showsupli(this.value);\"><option value=0>No</option>";
  echo "<option value=1>Yes</option>";
echo "</select>";// Closing of list box
echo "</td>";
echo "  </tr>";

echo "</table>";

echo "</form>";
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dt97868 2012-11-27 08:15

    The problem is your option values are 1 and 0, but in your Javascript you look for Yes.

    Change to:

    if (sta == '1')

    The selected value of a <select> is the selected <option> value, not the text.

    You also have a syntax error, you forgot to close the quote after ratesupli.php, use:'ratesupli.php','topFrame');
    解决 无用
    打赏 举报
  • dongxingqiu7943 2014-12-15 06:44

    html CHANGE

    <option value='0'>No</option>
    <option value='1'>Yes</option>

    Javascript change

    function showsupli(sta)
    alert ("sta");
    if (sta == '1')
    解决 无用
    打赏 举报

相关推荐 更多相似问题