首页 > 解决方案 > PHP 中的条件格式 JavaScript

问题描述

我是 js 和 php 的新手,实际上是一般的网页设计....

我有一个由大学学生建立的网站。它使用 PHP、JavaScript、Apache、AJAX、MySQL。遗憾的是项目已经完成,但我需要更改格式。 我有什么和我需要什么

我试图在我的电脑上安装 WAMP,但没有成功。相反,我在写字板中编辑 .js 文件并在服务器上将其换出。

//Currently the output from displaying a "law" on my website is this:
//The &plusmn 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("&plusmn; " + 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'>&plusmn" + 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("&plusmn; " + 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>" + &plusmn + 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("&plusmn; " + parseInt(jsonData.sd))
 $(".law-value").html(parseInt(jsonData.mean) + "&plusmn; " + 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 + &plusmn + event.SDBefore" + "</span></td>";

标签: javascriptjquery

解决方案


看看&plusmn;。这是您要更改为 的符号+/-


推荐阅读