javascript - PHP 中的条件格式 JavaScript
问题描述
我是 js 和 php 的新手,实际上是一般的网页设计....
我有一个由大学学生建立的网站。它使用 PHP、JavaScript、Apache、AJAX、MySQL。遗憾的是项目已经完成,但我需要更改格式。 我有什么和我需要什么
我试图在我的电脑上安装 WAMP,但没有成功。相反,我在写字板中编辑 .js 文件并在服务器上将其换出。
//Currently the output from displaying a "law" on my website is this:
//The ± and the second number (sd - in the code below SDBefore) is formatted green for 0<=sd <50.
//The first number (mean - in the code before meanBefore) is not formatted.
//AFAIK the javascript file on the server produces this is currently as follows:
$(".mean-value").html("Loading");
$(".sd-value").html("Loading");
//parse the returned data
var jsonData = JSON.parse(data);
$(".mean-value").html(parseInt(jsonData.mean));
$(".sd-value").html("± " + parseInt(jsonData.sd));
currentHTML = currentHTML + "<td><a href='./event-profile.php?id=" + event.event_id + "' >" + event.event_name + "</a></td>";
if(event.SDBefore >= 0 && event.SDBefore < 50)
{
currentHTML = currentHTML + "<td>" + event.meanBefore + "<span class='sd-value-green'>±" + event.SDBefore + "</span></td>";
}
//.....( JSON is a format for storing and transporting data).
//So what I want to do is one of the following a) or b)
// a) format the mean only according to 0<=sd <50.
Is this correct?
//parse the returned data
var jsonData = JSON.parse(data);
$(".mean-value").html(parseInt(jsonData.mean));
//$(".sd-value").html("± " + parseInt(jsonData.sd)); //Don't need this line
currentHTML = currentHTML + "<td><a href='./event-profile.php?id=" + event.event_id + "' >" + event.event_name + "</a></td>";
if(event.SDBefore >= 0 && event.SDBefore < 50)
{
currentHTML = currentHTML + "<td>" + "<span class='mean-value-green'>event.meanBefore+</span>" + ± + event.SDBefore + "</td>";
}
//b) format the whole law according to 0<=sd <50.
//So I have added the following (in bold):
// Is this correct?
$(".mean-value").html("Loading");
$(".sd-value").html("Loading");
$(".law-value").html("Loading");
//parse the returned data
var jsonData = JSON.parse(data);
$(".mean-value").html(parseInt(jsonData.mean));
$(".sd-value").html("± " + parseInt(jsonData.sd))
$(".law-value").html(parseInt(jsonData.mean) + "± " + parseInt(jsonData.sd));
currentHTML = currentHTML + "<td><a href='./event-profile.php?id=" + event.event_id + "' >" + event.event_name + "</a></td>";
if(event.SDBefore >= 0 && event.SDBefore < 50)
{
currentHTML = currentHTML + "<td>" + "<span class='law-value-green'> event.meanBefore + ± + event.SDBefore" + "</span></td>";
解决方案
看看±
。这是您要更改为 的符号+/-
。
推荐阅读
- rust - 如何使用 serde_json 从对象数组中反序列化单个字段?
- postgresql - 如何从postgres中具有最大计数的列中获取值?
- keyboard-shortcuts - Sublime text 2,如何为菜单项“查看-自动换行列-等”设置热键?
- node.js - npm install 在这么多警告后给出错误
- android - 运行时异常:ClassCastException android.os.Bundle 无法转换为 Parcelable 类
- android - 意图附加文本
- java - 配置的解决方案:projectname:classpathCopy 在没有以安全方式访问项目的情况下得到解决
- data-structures - 如何使用堆栈数据结构打印树(图)的两个节点之间的路径?
- php - 没有通过 Wordpress 用户元数据
- python - Django:使用 AbstractBaseUser 编辑配置文件