dongtigai3875 2015-04-20 15:40
浏览 52
已采纳

iTop,在哪里实现onchange javascript?

the iTop fourms are pretty inactive and I am pretty stuck so I thought I'd ask here if that is ok. I am attempting to add my own piece of javascript to work onchange of the iTop organization select bar.

Here is a link to iTop if needed: http://www.combodo.com/spip.php?page=rubrique&id_rubrique=8

Extra info on my iTop forum question, no answers yet: https://sourceforge.net/p/itop/discussion/922360/thread/dd1da92f/

So iTop is a piece of software made using php, html, js and css but I am new to php so I have ran into a little bit of a problem. I am trying to implement a piece of javascript which will change the top-bar of the css to a different colour based on organization, I made a small prototype independent of iTop and it works perfectly. However I am unable to add the onchange() method along with the javascript as the main user interface is generated dynamically using php. I have tried numerous ways to implement the javascript but none have worked. Here are some pictures of iTop and code to help:

This is a picture showing the inspect element of iTop and how I came to believe jquery-1.7.1.min.js may be the correct location to place the code.

Inspect element showing that jquery-1.7.1.min.js has a listener

So I have tried going into this file and copy and pasting in my Java Script code but in some locations it has no affect and within function(a){....} it results in iTop only displaying a blank page, I could be going about this totally wrong but from what I have seen this file seems to be the one I am to edit to get what I want.

here is the javascript i am trying to implement:

var changeStyle = function(){

    //HTML
    var selectedValue = document.getElementById("org_id").value;

    //CSS
    var trimColor = document.querySelector("#top-bar");

    //BT
    if(selectedValue=="3"){
        //change banner colour
        trimColor.style.backgroundColor= "#3498db";
    }

    //Bell Aliant
    else if(selectedValue=="27"){
        //change banner colour
        trimColor.style.backgroundColor= "#f1c40f";
    }

    //Bell Canada
     else if(selectedValue=="26"){
         trimColor.style.backgroundColor= "#e74c3c"; 
    }

    else
        trimColor.style.backgroundColor="#ecf0f1";
}

Here are some pictures of it working in my non iTop version of just HTML, JS and CSS:

Red

yellow

  • 写回答

1条回答 默认 最新

  • doudouba4520 2015-04-21 15:09
    关注

    Although I do not believe it is the best solution I have entered the following code into jquery-1.1.1.min.js as shown

    enter image description here

    And I have achieved the desired result, the trim now changes with the organization change, this however is not the perfect solution I was looking for and is a bit slow but not in the sense that you'd get annoyed, at least in my opinion. Mission Accomplished for the moment!

    enter image description hereenter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用
  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题