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

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 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题