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 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分