duanbei2914 2019-04-23 08:43
浏览 49

无法从PHP更改classNames [重复]

I'm trying to use a PHP-variable as a function argument, to change classNames of HTML elements by concatenating the function argument to a string.

I get the error: Uncaught SyntaxError: Unexpected end of input

its refering to this line, the 4 inputs that currently are spawned:

 <input type="button" id="2019-04-23 11:12:14" 
onclick="get_db("professor");" value="2019-04-23 11:12:14" /><br><input 
type="button" id="2019-04-23 11:12:19" onclick="get_db("professor");" 
value="2019-04-23 11:12:19" /><br><input type="button" id="2019-04-23 
11:12:21" onclick="get_db("professor");" value="2019-04-23 11:12:21" /><br>              
</div>

when I look in the debugger, it says get_db (professor) which is the correct username though.

Here is a DIV that I would like to hide at the press of the input button:

          <div id="professorshistory" class="tab-pane fade">
            <p><?php writeDate('22'); ?></p>

          </div>
    </div>

Here is the PHP. Rad means Row (swedish).

$username = $rad['username'];
$json = json_encode($username);

echo '<input type="button" id="'.$rad['dateofpost'].'" 
onclick="get_db('.$json.')" value="'.$rad['dateofpost'].'" > 
gheh </input>';

here is the script. the point would be that the function argument concatenates with "shistory", so if the argument gets the username "professor" from the sql database, then the function would reference the document with the ID of "professorshistory", and that hides the tab.

  function get_db(usernames){

  document.getElementById(usernames + "shistory").className = "tab-pane hide "
</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向