Search Results

Search found 461 results on 19 pages for 'parseint'.

Page 9/19 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Get Image Source URLs from a Different Page Using JS

    - by SDD
    Everyone: I'm trying to grab the source URLs of images from one page and use them in some JavaScript in another page. I know how to pull in images using JQuery .load(). However, rather than load all the images and display them on the page, I want to just grab the source URLs so I can use them in a JS array. Page 1 is just a page with images: <html> <head> </head> <body> <img id="image0" src="image0.jpg" /> <img id="image1" src="image1.jpg" /> <img id="image2" src="image2.jpg" /> <img id="image3" src="image3.jpg" /> </body> </html> Page 2 contains my JS. (Please note that the end goal is to load images into an array, randomize them, and using cookies, show a new image on page load every 10 seconds. All this is working. However, rather than hard code the image paths into my javascript as shown below, I'd prefer to take the paths from Page 1 based on their IDs. This way, the images won't always need to be titled "image1.jpg," etc.) <script type = "text/javascript"> var days = 730; var rotator = new Object(); var currentTime = new Date(); var currentMilli = currentTime.getTime(); var images = [], index = 0; images[0] = "image0.jpg"; images[1] = "image1.jpg"; images[2] = "image2.jpg"; images[3] = "image3.jpg"; rotator.getCookie = function(Name) { var re = new RegExp(Name+"=[^;]+", "i"); if (document.cookie.match(re)) return document.cookie.match(re)[0].split("=")[1]; return''; } rotator.setCookie = function(name, value, days) { var expireDate = new Date(); var expstring = expireDate.setDate(expireDate.getDate()+parseInt(days)); document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/"; } rotator.randomize = function() { index = Math.floor(Math.random() * images.length); randomImageSrc = images[index]; } rotator.check = function() { if (rotator.getCookie("randomImage") == "") { rotator.randomize(); document.write("<img src=" + randomImageSrc + ">"); rotator.setCookie("randomImage", randomImageSrc, days); rotator.setCookie("timeClock", currentMilli, days); } else { var writtenTime = parseInt(rotator.getCookie("timeClock"),10); if ( currentMilli > writtenTime + 10000 ) { rotator.randomize(); var writtenImage = rotator.getCookie("randomImage") while ( randomImageSrc == writtenImage ) { rotator.randomize(); } document.write("<img src=" + randomImageSrc + ">"); rotator.setCookie("randomImage", randomImageSrc, days); rotator.setCookie("timeClock", currentMilli, days); } else { var writtenImage = rotator.getCookie("randomImage") document.write("<img src=" + writtenImage + ">"); } } } rotator.check() </script> Can anyone point me in the right direction? My hunch is to use JQuery .get(), but I've been unsuccessful so far. Please let me know if I can clarify!

    Read the article

  • Problem in arranging contents of Class in JAVA

    - by LuckySlevin
    Hi, I have some classes and I'm trying to fill the objects of this class. Here is what i've tried. (Question is at the below) public class Team { private String clubName; private String preName; private ArrayList<String> branches; public Team(String clubName, String preName) { this.clubName = clubName; this.preName = preName; branches = new ArrayList<String>(); } public Team() { // TODO Auto-generated constructor stub } public String getClubName() { return clubName; } public String getPreName() { return preName; } public ArrayList<String> getBranches() { return branches; } public void setClubName(String clubName) { this.clubName = clubName; } public void setPreName(String preName) { this.preName = preName; } public void setBranches(ArrayList<String> branches) { this.branches = branches; } } public class Branch { private ArrayList<Player> players = new ArrayList<Player>(); String brName; public Branch() {} public void setBr(String brName){this.brName = brName;} public String getBr(){return brName;} public ArrayList<Player> getPlayers() { return players; } public void setPlayers(ArrayList<Player> players) { this.players = players; } } //TEST CLASS public class test { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { String a,b,c; String q = "q"; int brCount = 0, tCount = 0; BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); Team[] teams = new Team[30]; Branch[] myBranch = new Branch[30]; for(int z = 0 ; z <30 ;z++) { teams[z] = new Team(); myBranch[z] = new Branch(); } ArrayList<String> tmp = new ArrayList<String>(); int k = 0; int secim = Integer.parseInt(input.readLine()); while(secim != 0) { if(k!=0) secim = Integer.parseInt(input.readLine()); k++; switch(secim) { case 1 : brCount = 0; a = input.readLine(); teams[tCount].setClubName(a); b= input.readLine(); teams[tCount].setPreName(b); c = input.readLine(); while(c.equals(q) == false) { if(brCount != 0) {c = input.readLine();} if(c.equals(q)== false){ myBranch[brCount].brName = c; tmp.add(myBranch[brCount].brName); brCount++; } System.out.println(brCount); } teams[tCount].setBranches(tmp); for(int i=0;i<=tCount;i++ ){ System.out.print("a :" + teams[i].getClubName()+ " " + teams[i].getPreName()+ " "); System.out.println(teams[i].getBranches());} tCount++; break; case 2: String src = input.readLine();//LATERRRRRRRr } } } } The problem is one of my class elements. I have an arraylist as an element of a class. When i enter: AAA as preName BBB as clubName c d e as Branches Then as a second element www as preName GGG as clubName a b as branches The result is coming like: AAA BBB c,d,e,a,b GGG www c,d,e,a,b Which means ArrayList part of the class is putting it on and on. I tried to use clear() method but caused problems. Any ideas.

    Read the article

  • Java: Object Array assignment in for loop

    - by Hackster
    I am trying to use Dijkstra's algorithm to find the shortest path from a specific vertex (v0) to the rest of them. That is solved and works well with this code from this link below: http://en.literateprograms.org/index.php?title=Special:DownloadCode/Dijkstra%27s_algorithm_(Java)&oldid=15444 I am having trouble with assigning the Edge array in a for loop from the user input, as opposed to hard-coding it like it is here. Any help assigning a new edge to Edge[] adjacencies from each vertex? Keeping in mind it could be 1 or multiple edges. class Vertex implements Comparable<Vertex> { public final String name; public Edge[] adjacencies; public double minDistance = Double.POSITIVE_INFINITY; public Vertex previous; public Vertex(String argName) { name = argName; } public String toString() { return name; } public int compareTo(Vertex other){ return Double.compare(minDistance, other.minDistance); } } class Edge{ public final Vertex target; public final double weight; public Edge(Vertex argTarget, double argWeight){ target = argTarget; weight = argWeight; } } public static void main(String[] args) { Vertex v[] = new Vertex[3]; Vertex v[0] = new Vertex("Harrisburg"); Vertex v[1] = new Vertex("Baltimore"); Vertex v[2] = new Vertex("Washington"); v0.adjacencies = new Edge[]{ new Edge(v[1], 1), new Edge(v[2], 3) }; v1.adjacencies = new Edge[]{ new Edge(v[0], 1), new Edge(v[2], 1),}; v2.adjacencies = new Edge[]{ new Edge(v[0], 3), new Edge(v[1], 1) }; Vertex[] vertices = { v0, v1, v2}; /*Three vertices with weight: V0 connects (V1,1),(V2,3) V1 connects (V0,1),(V2,1) V2 connects (V1,1),(V2,3) */ computePaths(v0); for (Vertex v : vertices){ System.out.println("Distance to " + v + ": " + v.minDistance); List<Vertex> path = getShortestPathTo(v); System.out.println("Path: " + path); } } } The above code works well in finding the shortest path from v0 to all the other vertices. The problem occurs when assigning the new edge[] to edge[] adjacencies. For example this does not produce the correct output: for (int i = 0; i < total_vertices; i++){ s = br.readLine(); char[] line = s.toCharArray(); for (int j = 0; j < line.length; j++){ if(j % 4 == 0 ){ //Input: vertex weight vertex weight: 1 1 2 3 int vert = Integer.parseInt(String.valueOf(line[j])); int w = Integer.parseInt(String.valueOf(line[j+2])); v[i].adjacencies = new Edge[] {new Edge(v[vert], w)}; } } } As opposed to this: v0.adjacencies = new Edge[]{ new Edge(v[1], 1), new Edge(v[2], 3) }; How can I take the user input and make an Edge[], to pass it to adjacencies? The problem is it could be 0 edges or many. Any help would be much appreciated Thanks!

    Read the article

  • Android: Set a random image using setImageResource

    - by Tom Jones
    I need a help with setting a random image using setImageResource method. In the drawable folder, I have a jpeg file named photo0.jpg, photo1.jpg...photo99.jpg. And the following code works: int p = R.drawable.photo1; image.setImageResource(p); The above will display photo1.jpg but I want to show a random image. I tried the following but it doesn't work. String a = "R.drawable.photo"; int n = (int) (Math.random()*100) String b = Integer.toString(n); String c = a+b; int p = Integer.parseInt(c);//checkpoint image.setImageResource(p); It seems like the string "R.drawable.photoXX" isn't being changed to integer at the checkpoint. Could someone please teach me a right code? Thank you in advance.

    Read the article

  • How to fix flicker when using Webkit transforms & transitions

    - by gargantaun
    I have a very simple demo working that uses Webkit transforms and transitions for smooth horizontal scrolling between 'panels' (divs). The reason I want to go this route as opposed to a Javascript driven system is that it's for the iPad and Javascript performance is quite poor, but the css transforms and transitions are smooth as silk. Sadly though, I'm getting a lot of flicker on the iPad with my Demo. You can see the demo here You'll need safari or and iPad to see it in action. I've never seen this happening in any of the demos for transforms and transitions so I'm hopeful that this is fixable. Anyway here's the code that powers the thing.... The HTML looks like this. <html> <head> <title>Swipe Demo</title> <link href="test.css" rel="stylesheet" /> <link href="styles.css" rel="stylesheet" /> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="functions.js"></script> <script type="text/javascript" src="swiping.js"></script> </head> <body> <div id="wrapper"> <div class='panel one'> <h1>This is panel 1</h1> </div> <div class='panel two'> <h1>This is panel 2</h1> </div> <div class='panel three'> <h1>This is panel 3</h1> </div> <div class='panel four'> <h1>This is panel 4</h1> </div> </div> </body> </html> The CSS looks like this body, html { padding: 0; margin: 0; background: #000; } #wrapper { width: 10000px; -webkit-transform: translateX(0px); } .panel { width: 1024px; height: 300px; background: #fff; display: block; float: left; position: relative; } and the javascript looks like this // Mouse / iPad Touch var touchSupport = (typeof Touch == "object"), touchstart = touchSupport ? 'touchstart' : 'mousedown', touchmove = touchSupport ? 'touchmove' : 'mousemove', touchend = touchSupport ? 'touchend' : 'mouseup'; $(document).ready(function(){ // set top and left to zero $("#wrapper").css("top", 0); $("#wrapper").css("left", 0); // get total number of panels var panelTotal; $(".panel").each(function(){ panelTotal += 1 }); // Touch Start // ------------------------------------------------------------------------------------------ var touchStartX; var touchStartY; var currentX; var currentY; var shouldMove = false; document.addEventListener(touchstart, swipeStart, false); function swipeStart(event){ touch = realEventType(event); touchStartX = touch.pageX; touchStartY = touch.pageY; var pos = $("#wrapper").position(); currentX = parseInt(pos.left); currentY = parseInt(pos.top); shouldMove = true; } // Touch Move // ------------------------------------------------------------------------------------------ var touchMoveX; var touchMoveY; var distanceX; var distanceY; document.addEventListener(touchmove, swipeMove, false); function swipeMove(event){ if(shouldMove){ touch = realEventType(event); event.preventDefault(); touchMoveX = touch.pageX; touchMoveY = touch.pageY; distanceX = touchMoveX - touchStartX; distanceY = touchMoveY - touchStartY; movePanels(distanceX); } } function movePanels(distance){ newX = currentX + (distance/4); $("#wrapper").css("left", newX); } // Touch End // ------------------------------------------------------------------------------------------ var cutOff = 100; var panelIndex = 0; document.addEventListener(touchend, swipeEnd, false); function swipeEnd(event){ touch = (touchSupport) ? event.changedTouches[0] : event; var touchEndX = touch.pageX; var touchEndY = touch.pageY; updatePanelIndex(distanceX); gotToPanel(); shouldMove = false; } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function updatePanelIndex(distance){ if(distanceX > cutOff) panelIndex -= 1; if(distanceX < (cutOff * -1)){ panelIndex += 1; } if(panelIndex < 0){ panelIndex = 0; } if(panelIndex >= panelTotal) panelIndex = panelTotal -1; console.log(panelIndex); } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function gotToPanel(){ var panelPos = getTotalWidthOfElement($(".panel")) * panelIndex * -1; $("#wrapper").css("-webkit-transition-property", "translateX"); $("#wrapper").css("-webkit-transition-duration", "1s"); $("#wrapper").css("-webkit-transform", "translateX("+panelPos+"px)"); } }); function realEventType(event){ e = (touchSupport) ? event.targetTouches[0] : event; return e; }

    Read the article

  • yui datatable inline cell editor problem

    - by Eli
    Hi, When using inline cell editor in my datatable I want to round value to 10 multiple This is my code : mydatatable.subscribe("cellDblclickEvent",datatable_DetailsCommande.onEventShowCellEditor); var onCellEdit = function(oArgs) { var oColumn=oArgs.editor.getColumn(); var column=oColumn.getKey(); var oRecord = oArgs.editor.getRecord(); var newValue=oRecord.getData(column); var row = this.getRecord(oArgs.target); // calculate the modulo n = newValue % 10; if(n!=0) { newValue=parseInt(newValue); oRecord.setData(column,eval(newValue+(10-n))); } } mydatatable.subscribe("editorSaveEvent", onCellEdit); Function result : After double clicking in cell I change value to 17 for example and I click save, I want then to have 20 in my datatable cell but I got 17. After second time double clicking in my datatable cell I obtain 20 in the inline cell editor. How to put the rounded value in my datatable cell? regards,

    Read the article

  • why is this closing the new pop up window

    - by user295189
    I am trying to open a window and then redirecting the original page to a new location. It opens the window, however before redirecting the parent page, it closes the new window too. How can I fix that function orderPrint() { var n = new Object(); n. ID = <?php echo $ID->ID; ?>; n.action = posttothispage.php"; n.target = popWinCenterScreen("/common/html/empty.htm", parseInt(window.screen.height * 0.8), 796, "resize"); myFuction.PostRequest(n); window.location = “someotherpagethanthis.php”; }

    Read the article

  • BufferedReader.readLine() gives error java.net.SocketException: Software caused connection abort: re

    - by javatcp
    I am trying to code my program such that until the buffered reader gets something in readLine() from my tcp client it should keep running in the while loop checking but I get this error as soon as the program executes Mar 31, 2010 11:03:36 PM deswash.DESWashView$5 run SEVERE: null java.net.SocketException: Software caused connection abort: recv failed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) at java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at java.io.BufferedReader.readLine(BufferedReader.java:299) at java.io.BufferedReader.readLine(BufferedReader.java:362) at deswash.DESWashView$5.run(DESWashView.java:448) the second line in the following code throws the error while(running){ String temp = in.readLine(); if(!(temp.equals(null))){ int inid = Integer.parseInt(temp); stationList.add(inid); } }

    Read the article

  • Understanding try..catch in Javascript

    - by user295189
    I have this try and catch problem. I am trying to redirect to a different page. But sometimes it does and some times it doesnt. I think the problem is in try and catch . can someone help me understand this. Thanks var pg = new Object(); var da = document.all; var wo = window.opener; pg.changeHideReasonID = function(){ if(pg.hideReasonID.value == 0 && pg.hideReasonID.selectedIndex > 0){ pg.otherReason.style.backgroundColor = "ffffff"; pg.otherReason.disabled = 0; pg.otherReason.focus(); } else { pg.otherReason.style.backgroundColor = "f5f5f5"; pg.otherReason.disabled = 1; } } pg.exit = function(pid){ try { if(window.opener.hideRecordReload){ window.opener.hideRecordReload(pg.recordID, pg.recordTypeID); } else { window.opener.pg.hideRecord(pg.recordID, pg.recordTypeID); } } catch(e) {} try { window.opener.pg.hideEncounter(pg.recordID); } catch(e) {} try { window.opener.pg.hideRecordResponse(pg.hideReasonID.value == 0 ? pg.otherReason.value : pg.hideReasonID.options[pg.hideReasonID.selectedIndex].text); } catch(e) {} try { window.opener.pg.hideRecord_Response(pg.recordID, pg.recordTypeID); } catch(e) {} try { window.opener.pg.hideRecord_Response(pg.recordID, pg.recordTypeID); } catch(e) {} try { window.opener.window.parent.frames[1].pg.loadQualityMeasureRequest(); } catch(e) {} try { window.opener.pg.closeWindow(); } catch(e) {} parent.loadCenter2({reportName:'redirectedpage',patientID:pid}); parent.$.fancybox.close(); } pg.hideRecord = function(){ var pid = this.pid; pg.otherReason.value = pg.otherReason.value.trim(); if(pg.hideReasonID.selectedIndex == 0){ alert("You have not indicated your reason for hiding this record."); pg.hideReasonID.focus(); } else if(pg.hideReasonID.value == 0 && pg.hideReasonID.selectedIndex > 0 && pg.otherReason.value.length < 2){ alert("You have indicated that you wish to enter a reason\nnot on the list, but you have not entered a reason."); pg.otherReason.focus(); } else { pg.workin(1); var n = new Object(); n.noheaders = 1; n.recordID = pg.recordID; n.recordType = pg.recordType; n.recordTypeID = pg.recordTypeID; n.encounterID = request.encounterID; n.hideReasonID = pg.hideReasonID.value; n.hideReason = pg.hideReasonID.value == 0 ? pg.otherReason.value : pg.hideReasonID.options[pg.hideReasonID.selectedIndex].text; Connect.Ajax.Post("/emr/hideRecord/act_hideRecord.php", n, pg.exit(pid)); } } pg.init = function(){ pg.blocker = da.blocker; pg.hourglass = da.hourglass; pg.content = da.pageContent; pg.recordType = da.recordType.value; pg.recordID = parseInt(da.recordID.value); pg.recordTypeID = parseInt(da.recordTypeID.value); pg.information = da.information; pg.hideReasonID = da.hideReasonID; pg.hideReasonID.onchange = pg.changeHideReasonID; pg.hideReasonID.tabIndex = 1; pg.otherReason = da.otherReason; pg.otherReason.tabIndex = 2; pg.otherReason.onblur = function(){ this.value = this.value.trim(); } pg.otherReason.onfocus = function(){ this.select(); } pg.btnCancel = da.btnCancel; pg.btnCancel.tabIndex = 4; pg.btnCancel.title = "Close this window"; pg.btnCancel.onclick = function(){ //window.close(); parent.$.fancybox.close(); } pg.btnHide = da.btnHide; pg.btnHide.tabIndex = 3; pg.btnHide.onclick = pg.hideRecord; pg.btnHide.title = "Hide " + pg.recordType.toLowerCase() + " record"; document.body.onselectstart = function(){ if(event.srcElement.tagName.search(/INPUT|TEXT/i)){ return false; } } pg.workin(0); } pg.workin = function(){ var n = arguments.length ? arguments[0] : 1; pg.content.disabled = pg.hideReasonID.disabled = n; pg.blocker.style.display = pg.hourglass.style.display = n ? "block" : "none"; if(n){ pg.otherReason.disabled = 1; pg.otherReason.style.backgroundColor = "f5f5f5"; } else { pg.otherReason.disabled = !(pg.hideReasonID.value == 0 && pg.hideReasonID.selectedIndex > 0); pg.otherReason.style.backgroundColor = pg.otherReason.disabled ? "f5f5f5" : "ffffff"; pg.hideReasonID.focus(); } }

    Read the article

  • Large number array compression

    - by gatapia
    Hi All, I've got a javascript application that sends a large amount of numerical data down the wire. This data is then stored in a database. I am having size issues (too much bandwidth, database getting too big). I am now ready to sacrifice some performance for compression. I was thinking of implementing a base 62 number.toString(62) and parseInt(compressed, 62). This would certainly reduce the size of the data but before I go ahead and do this I thought I would put it to the folks here as I know there must be some outside the box solution I have not considered. The basic specs are: - Compress large number arrays into strings for JSONP transfer (So I think UTF is out) - Be relatively fast, look I'm not expecting same performance as I have now but I also don't want gzip compression either. Any ideas would be greatly appreciated. Thanks Guido Tapia

    Read the article

  • substring IP address in java

    - by m2010
    This program takes string like that 192.168.1.125 and cut every number then converts it to integer, but it returns an error. import java.lang.String; import java.lang.Number; import java.lang.Integer; class Ip { public static void main ( String [] args ) { int i ; i = args[0].indexOf ( '.' ); do { if ( i != -1 ) args[0].substring ( 0, i ); String str = args[0].substring ( i + 1, args[0].length() ); String str2 = Integer.parseInt ( str ); System.out.println ( str2 ); } while ( i != -1 ); } }

    Read the article

  • Add a thousands separator to a total with Javascript or jQuery?

    - by Matt
    I have a function that sums a column of data in an html table. It does so admirably only I would like to have it put the commas in there that are needed to separate the thousands. Initially, you'll note, there are commas in the numbers being added. So that the function will add them, they are removed. How do I add the commas back in there? <script type="text/javascript"> function sumOfColumns(tableID, columnIndex, hasHeader) { var tot = 0; $("#" + tableID + " tr" + (hasHeader ? ":gt(0)" : "")) .children("td:nth-child(" + columnIndex + ")") .each(function() { tot += parseInt($(this).html().replace(',', '')); }); return "Total Pounds Entered : " + tot; } </script>

    Read the article

  • help me understand try and catch

    - by user295189
    I have this try and catch problem. I am trying to redirect to a different page. But sometimes it does and some times it doesnt. I think the problem is in try and catch . can someone help me understand this. Thanks var pg = new Object(); var da = document.all; var wo = window.opener; pg.changeHideReasonID = function(){ if(pg.hideReasonID.value == 0 && pg.hideReasonID.selectedIndex > 0){ pg.otherReason.style.backgroundColor = "ffffff"; pg.otherReason.disabled = 0; pg.otherReason.focus(); } else { pg.otherReason.style.backgroundColor = "f5f5f5"; pg.otherReason.disabled = 1; } } pg.exit = function(pid){ try { if(window.opener.hideRecordReload){ window.opener.hideRecordReload(pg.recordID, pg.recordTypeID); } else { window.opener.pg.hideRecord(pg.recordID, pg.recordTypeID); } } catch(e) {} try { window.opener.pg.hideEncounter(pg.recordID); } catch(e) {} try { window.opener.pg.hideRecordResponse(pg.hideReasonID.value == 0 ? pg.otherReason.value : pg.hideReasonID.options[pg.hideReasonID.selectedIndex].text); } catch(e) {} try { window.opener.pg.hideRecord_Response(pg.recordID, pg.recordTypeID); } catch(e) {} try { window.opener.pg.hideRecord_Response(pg.recordID, pg.recordTypeID); } catch(e) {} try { window.opener.window.parent.frames[1].pg.loadQualityMeasureRequest(); } catch(e) {} try { window.opener.pg.closeWindow(); } catch(e) {} parent.loadCenter2({reportName:'redirectedpage',patientID:pid}); parent.$.fancybox.close(); } pg.hideRecord = function(){ var pid = this.pid; pg.otherReason.value = pg.otherReason.value.trim(); if(pg.hideReasonID.selectedIndex == 0){ alert("You have not indicated your reason for hiding this record."); pg.hideReasonID.focus(); } else if(pg.hideReasonID.value == 0 && pg.hideReasonID.selectedIndex > 0 && pg.otherReason.value.length < 2){ alert("You have indicated that you wish to enter a reason\nnot on the list, but you have not entered a reason."); pg.otherReason.focus(); } else { pg.workin(1); var n = new Object(); n.noheaders = 1; n.recordID = pg.recordID; n.recordType = pg.recordType; n.recordTypeID = pg.recordTypeID; n.encounterID = request.encounterID; n.hideReasonID = pg.hideReasonID.value; n.hideReason = pg.hideReasonID.value == 0 ? pg.otherReason.value : pg.hideReasonID.options[pg.hideReasonID.selectedIndex].text; Connect.Ajax.Post("/emr/hideRecord/act_hideRecord.php", n, pg.exit(pid)); } } pg.init = function(){ pg.blocker = da.blocker; pg.hourglass = da.hourglass; pg.content = da.pageContent; pg.recordType = da.recordType.value; pg.recordID = parseInt(da.recordID.value); pg.recordTypeID = parseInt(da.recordTypeID.value); pg.information = da.information; pg.hideReasonID = da.hideReasonID; pg.hideReasonID.onchange = pg.changeHideReasonID; pg.hideReasonID.tabIndex = 1; pg.otherReason = da.otherReason; pg.otherReason.tabIndex = 2; pg.otherReason.onblur = function(){ this.value = this.value.trim(); } pg.otherReason.onfocus = function(){ this.select(); } pg.btnCancel = da.btnCancel; pg.btnCancel.tabIndex = 4; pg.btnCancel.title = "Close this window"; pg.btnCancel.onclick = function(){ //window.close(); parent.$.fancybox.close(); } pg.btnHide = da.btnHide; pg.btnHide.tabIndex = 3; pg.btnHide.onclick = pg.hideRecord; pg.btnHide.title = "Hide " + pg.recordType.toLowerCase() + " record"; document.body.onselectstart = function(){ if(event.srcElement.tagName.search(/INPUT|TEXT/i)){ return false; } } pg.workin(0); } pg.workin = function(){ var n = arguments.length ? arguments[0] : 1; pg.content.disabled = pg.hideReasonID.disabled = n; pg.blocker.style.display = pg.hourglass.style.display = n ? "block" : "none"; if(n){ pg.otherReason.disabled = 1; pg.otherReason.style.backgroundColor = "f5f5f5"; } else { pg.otherReason.disabled = !(pg.hideReasonID.value == 0 && pg.hideReasonID.selectedIndex > 0); pg.otherReason.style.backgroundColor = pg.otherReason.disabled ? "f5f5f5" : "ffffff"; pg.hideReasonID.focus(); } }

    Read the article

  • I am getting exception in main thread...even when i am handling the exception

    - by fari
    public KalaGame(KeyBoardPlayer player1,KeyBoardPlayer player2) { //super(0); int key=0; try { do{ System.out.println("Enter the number of stones to play with: "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); key = Integer.parseInt(br.readLine()); if(key<0 || key>10) throw new InvalidStartingStonesException(key); } while(key<0 || key>10); player1=new KeyBoardPlayer(); player2 = new KeyBoardPlayer(); this.player1=player1; this.player2=player2; state=new KalaGameState(key); } catch(IOException e) { System.out.println(e); } } when i enter an invalid number of stones i get this error Exception in thread "main" InvalidStartingStonesException: The number of starting stones must be greater than 0 and less than or equal to 10 (attempted 22) why isn't the exception handled by the throw i defined at KalaGame.<init>(KalaGame.java:27) at PlayKala.main(PlayKala.java:10)

    Read the article

  • What's the easiest way to parse numbers in clojure?

    - by Rob Lachlan
    I've been using java to parse numbers, e.g. (. Integer parseInt numberString) Is there a more clojuriffic way that would handle both integers and floats, and return clojure numbers? I'm not especially worried about performance here, I just want to process a bunch of white space delimited numbers in a file and do something with them, in the most straightforward way possible. So a file might have lines like: 5 10 0.0002 4 12 0.003 And I'd like to be able to transform the lines into vectors of numbers.

    Read the article

  • Changing name attr of cloned input element in jQuery doesn't work in IE6/7

    - by BalusC
    This SSCCE says it all: <!doctype html> <html lang="en"> <head> <title>Test</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#add').click(function() { var ul = $('#ul'); var liclone = ul.find('li:last').clone(true); var input = liclone.find('input'); input.attr('name', input.attr('name').replace(/(foo\[)(\d+)(\])/, function(f, p1, p2, p3) { return p1 + (parseInt(p2) + 1) + p3; })); liclone.appendTo(ul); $('#showsource').text(ul.html()); }); }); </script> </head> <body> <ul id="ul"> <li><input type="text" name="foo[0]"></li> </ul> <button id="add">Add</button> <pre id="showsource"></pre> </body> </html> Copy'n'paste'n'run it, click the Add button several times. On every click you should see the HTML code of the <ul> to show up in the <pre id="showsource"> and the expected code should roughly be: <li><input name="foo[0]" type="text"></li> <li><input name="foo[1]" type="text"></li> <li><input name="foo[2]" type="text"></li> <li><input name="foo[3]" type="text"></li> This works as expected in FF, Chrome, Safari, Opera and IE8. However, IE6/7 fails in changing the name attribute and produces like: <li><input name="foo[0]" type="text"> <li><input name="foo[0]" type="text"> <li><input name="foo[0]" type="text"> <li><input name="foo[0]" type="text"></li> I googled a bit and found this very similar problem, he fixed it and posted a code snippet how it should have look like. Unfortunately this is exactly what I already have done, so I suspect that he was only testing in IE8, not in IE6/7. Other than that particular topic Google didn't reveal much. Any insights? Or do I really have to grab back to document.createElement? Note: I know that I can use just the same name for each input element and retrieve them as an array, but the above is just a basic example, in real I really need to have the name attribute changed, because it not only contains the index, but also other information such as parentindex, ordering, etc. It's been used to add/rearrange/remove (sub)menu items. Edit: this is related to this bug, The jQuery (I'm using 1.3.2) does thus not seem to create inputs that way? The following does just work: $('#add').click(function() { var ul = $('#ul'); var liclone = ul.find('li:last').clone(true); var oldinput = liclone.find('input'); var name = oldinput.attr('name').replace(/(foo\[)(\d+)(\])/, function(f, p1, p2, p3) { return p1 + (parseInt(p2) + 1) + p3; }); var newinput = $('<input name="' + name + '">'); oldinput.replaceWith(newinput); liclone.appendTo(ul); $('#showsource').text(ul.html()); }); But I can't imagine that I am the only one who encountered this problem with jQuery. Even a simple $('<input>').attr('name', 'foo') doesn't work in IE6/7. Isn't jQuery as being a crossbrowser library supposed to cover this particular issue under the hoods?

    Read the article

  • Hibernate Query Language Problem

    - by Sarang
    Well, I have implemented a distinct query in hibernate. It returns me result. But, while casting the fields are getting interchanged. So, it generates casting error. What should be the solution? As an example, I do have database, "ProjectAssignment" that has three fields, aid, pid & userName. I want all distinct userName data from this table. I have applied query : select distinct userName, aid, pid from ProjectAssignment Whereas the ProjectAssignment.java file has the fields in sequence aid, pid & userName. Now, here the userName is first field in output. So, Casting is not getting possible. Also, query : select aid, pid, distinct userName from ProjectAssignment is not working. What is the proper query for the same ? Or what else the solution ? The code is as below : System Utilization Service Bean Method where I have to retrieve data : public List<ProjectAssignment> getProjectAssignments() { projectAssignments = ProjectAssignmentHelper.getAllResources(); //Here comes the error return projectAssignments; } ProjectAssignmentHelper from where I fetch Data : package com.hibernate; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; public class ProjectAssignmentHelper { public static List<ProjectAssignment> getAllResources() { List<ProjectAssignment> projectMasters; Session session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("select distinct aid, pid, userName from ProjectAssignment"); projectMasters = (List<ProjectAssignment>) query.list(); session.close(); return projectMasters; } } Hibernate Data Bean : package com.hibernate; public class ProjectAssignment implements java.io.Serializable { private short aid; private String pid; private String userName; public ProjectAssignment() { } public ProjectAssignment(short aid) { this.aid = aid; } public ProjectAssignment(short aid, String pid, String userName) { this.aid = aid; this.pid = pid; this.userName = userName; } public short getAid() { return this.aid; } public void setAid(short aid) { this.aid = aid; } public String getPid() { return this.pid; } public void setPid(String pid) { this.pid = pid; } public String getUserName() { return this.userName; } public void setUserName(String userName) { this.userName = userName; } } Error : For input string: "userName" java.lang.NumberFormatException: For input string: "userName" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at javax.el.ArrayELResolver.toInteger(ArrayELResolver.java:375) at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:195) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at com.sun.el.parser.AstValue.getValue(AstValue.java:116) at com.sun.el.parser.AstValue.getValue(AstValue.java:163) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178) at javax.faces.component.UICommand.getValue(UICommand.java:218) at org.primefaces.component.commandlink.CommandLinkRenderer.encodeMarkup(CommandLinkRenderer.java:113) at org.primefaces.component.commandlink.CommandLinkRenderer.encodeEnd(CommandLinkRenderer.java:54) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70) at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:54) at org.primefaces.component.datatable.DataTableRenderer.encodeTable(DataTableRenderer.java:525) at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:407) at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:193) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70) at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:54) at org.primefaces.component.tabview.TabViewRenderer.encodeContents(TabViewRenderer.java:198) at org.primefaces.component.tabview.TabViewRenderer.encodeMarkup(TabViewRenderer.java:130) at org.primefaces.component.tabview.TabViewRenderer.encodeEnd(TabViewRenderer.java:48) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620) at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:802) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:664) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:497) at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:468) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:364) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314) at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:783) at org.apache.jsp.welcome_jsp._jspService(welcome_jsp.java from :59) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:406) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:483) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:373) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:619)

    Read the article

  • Embedded media player gets inconsistent currentPosition on both IE8 and Firefox3

    - by logoin
    I have a embedded media player in the browser that is controlled by javascript to handle all the mediaChange event. The code looks like mediaChangeHandler: function(media) { if (media && this.offset && !this.offsetJumpPerformed) { if (parseFloat(media.duration) > this.offset) { pos = parseInt(pos); this.getPlayer().controls.currentPosition = pos; alert("jump to position: " + this.getPlayer().controls.currentPosition); this.play(); this.offsetJumpPerformed = true; alert("currentPosition:" + this.getPlayer().controls.currentPosition); } } } The first alert indicates the currentPosition is where I want it to be. However, the second alert would get currentPosition that's couple seconds less than what I have set up. Does anyone have idea why? I tried googled it but haven't found anything useful. Thanks!

    Read the article

  • Using only alphanumeric characters(a-z) inside toCharArray

    - by Aaron
    Below you will find me using toCharArray in order to send a string to array. I then MOVE the value of the letter using a for statement... for(i = 0; i < letter.length; i++){ letter[i] += (shiftCode); System.out.print(letter[i]); } However, when I use shiftCode to move the value such as... a shifted by -1; I get a symbol @. Is there a way to send the string to shiftCode or tell shiftCode to ONLY use letters? I need it to see my text, like "aaron", and when I use the for statement iterate through a-z only and ignore all symbols and numbers. I THINK it is as simple as... letter=codeWord.toCharArray(a,z); But trying different forms of that and googling it didn't give me any results. Perhaps it has to do with regex or something? Below you will find a complete copy of my program; it works exactly how I want it to do; but it iterates through letters and symbols. I also tried finding instructions online for toCharArray but if there exists any arguments I can't locate them. My program... import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* * Aaron L. Jones * CS219 * AaronJonesProg3 * * This program is designed to - * Work as a Ceasar Cipher */ /** * * Aaron Jones */ public class AaronJonesProg3 { static String codeWord; static int shiftCode; static int i; static char[] letter; /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { // Instantiating that Buffer Class // We are going to use this to read data from the user; in buffer // For performance related reasons BufferedReader reader; // Building the reader variable here // Just a basic input buffer (Holds things for us) reader = new BufferedReader(new InputStreamReader(System.in)); // Java speaks to us here / We get it to query our user System.out.print("Please enter text to encrypt: "); // Try to get their input here try { // Get their codeword using the reader codeWord = reader.readLine(); // Make that input upper case codeWord = codeWord.toUpperCase(); // Cut the white space out codeWord = codeWord.replaceAll("\\s",""); // Make it all a character array letter = codeWord.toCharArray(); } // If they messed up the input we let them know here and end the prog. catch(Throwable t) { System.out.println(t.toString()); System.out.println("You broke it. But you impressed me because" + "I don't know how you did it!"); } // Java Speaks / Lets get their desired shift value System.out.print("Please enter the shift value: "); // Try for their input try { // We get their number here shiftCode = Integer.parseInt(reader.readLine()); } // Again; if the user broke it. We let them know. catch(java.lang.NumberFormatException ioe) { System.out.println(ioe.toString()); System.out.println("How did you break this? Use a number next time!"); } for(i = 0; i < letter.length; i++){ letter[i] += (shiftCode); System.out.print(letter[i]); } System.out.println(); /**************************************************************** **************************************************************** ***************************************************************/ // Java speaks to us here / We get it to query our user System.out.print("Please enter text to decrypt: "); // Try to get their input here try { // Get their codeword using the reader codeWord = reader.readLine(); // Make that input upper case codeWord = codeWord.toUpperCase(); // Cut the white space out codeWord = codeWord.replaceAll("\\s",""); // Make it all a character array letter = codeWord.toCharArray(); } // If they messed up the input we let them know here and end the prog. catch(Throwable t) { System.out.println(t.toString()); System.out.println("You broke it. But you impressed me because" + "I don't know how you did it!"); } // Java Speaks / Lets get their desired shift value System.out.print("Please enter the shift value: "); // Try for their input try { // We get their number here shiftCode = Integer.parseInt(reader.readLine()); } // Again; if the user broke it. We let them know. catch(java.lang.NumberFormatException ioe) { System.out.println(ioe.toString()); System.out.println("How did you break this? Use a number next time!"); } for(i = 0; i < letter.length; i++){ letter[i] += (shiftCode); System.out.print(letter[i]); } System.out.println(); } }

    Read the article

  • StackOverflowError being caused by a TableModelListener

    - by me_here
    I'm not sure why this is recursing. jTable1.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent evt) { int sum = 0; int i=0; for (i =0 ; i<2; i++){ sum = sum + Integer.parseInt(jTable1.getValueAt(0, i).toString()); } jTable1.setValueAt(sum, 0, 2); } }); The exception is: (it keeps repeating) Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:277) at javax.swing.JTable.convertColumnIndexToModel(JTable.java:2553) at javax.swing.JTable.getValueAt(JTable.java:2695) at testprogram.guitest.TestTableModel$1.tableChanged(TestTableModel.java:63) at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280) at javax.swing.table.AbstractTableModel.fireTableCellUpdated(AbstractTableModel.java:259) at javax.swing.table.DefaultTableModel.setValueAt(DefaultTableModel.java:650) at javax.swing.JTable.setValueAt(JTable.java:2719) Any help appreciated.

    Read the article

  • Intent.getInt() doesn't work on ICS, but works on JB

    - by ObAt
    I use this code to send parameters when I start a new Activity: Intent inputForm = new Intent(getActivity(), InputForm.class); Bundle b = new Bundle(); b.putInt("item", Integer.parseInt(mItem.id)); //Your id inputForm.putExtras(b); //Put your id to your next Intent startActivity(inputForm); And I use this code for reading the parameters in the inputForm Activity: Bundle b = getIntent().getExtras(); if (b != null) { int value = b.getInt("item"); ID = value; } Toast.makeText(getApplication(), "MIJN ID:" + Integer.toString(ID), Toast.LENGTH_LONG).show(); When I run this code on my Samsung Tab 10.1 GT-P7510 ID is alsways 0, when I run the same code on my Galaxy S3 with JB the code just works fine. Can someone help me? Thanks in advance, ObAt

    Read the article

  • Why doesn't an octal literal as a string cast to a number?

    - by Andy E
    In JavaScript, why does an octal number string cast as a decimal number? I can cast a hex literal string using Number() or +, why not an octal? For instance: 1000 === +"1000" // -> true 0xFF === +"0xFF" // -> true 0100 === +"0100" // -> false - +"0100" gives 100, not 64 I know I can parse with parseInt("0100" [, 8]), but I'd like to know why casting doesn't work like it does with hex and dec numbers. Also, does anyone know why octal literals are dropped from ECMAScript 5th Edition in strict mode?

    Read the article

  • Bluimp file upload send data to the server on .fileupload

    - by MyName
    OK I've Googled...Googled and Googled again with no avail on how I can send data to the server like an ajax call's data option for the file upload: $('#file_upload').fileupload({ dataType: 'json', url: "@(Url.Action("UploadFiles", "ExcelUpload"))", // formData: function(form) { return [{ name: "dataTable", value : "@(Model)"}];}, progressall: function (e, data) { $(this).find('.progressbar').progressbar({ value: parseInt(data.loaded / data.total * 100, 10) }); }, done: function (e, data) { BadFile(e, data); } }); controller would look something like this: [HttpPost] public ContentResult UploadFiles(Mytype param1, MyType Param2) { .. } I want to do something similar to this: $.ajax({ url: "@(Url.Action("Action", "Controller"))", type: "post", data: { param1: value, param2: @(Model) } }); On the fileupload callback. Is this possible? How can I pass values to the ServerSide? Should I switch to a different uploader..? Please help me out! I need to resolve this as soon as possible.

    Read the article

  • What logic operator to use, as3?

    - by VideoDnd
    What operator or expression can I use that will fire on every number, including zero? I want a logic operator that will fire with ever number it receives. My animations pause at zero. This skips on zero if (numberThing> 0); This skips on 9 if (numberThing>> 0); This jitters 'fires quickly and goes back on count' if (numberThing== 0); EXPLANATION I'm catching split string values in a logic function, and feeding them to a series of IF, ELSE IF statements. I'm using this with a timer, so I can measure the discrepency. CODE • I GET VALUES FROM TIMER • STRING GOES TO TEXTFIELD 'substr' • NUMBER TRIGGERS TWEENS 'parseInt' • Goes to series of IF and ELSE IF statements

    Read the article

  • Extended with advice: Moving block wont work in Javascript

    - by Mack
    Hello Note: this is an extension of a question I just asked, i have made the edits & taken the advice but still no luck I am trying to make a webpage where when you click a link, the link moves diagonally every 100 milliseconds. So I have my Javascript, but right now when I click the link nothing happens. I have run my code through JSLint (therefore changed comaprisions to === not ==, thats weird in JS?). I get this error from JSLink though: Error: Implied global: self 15,38, document 31 What do you think I am doing wrong? <script LANGUAGE="JavaScript" type = "text/javascript"> <!-- var block = null; var clockStep = null; var index = 0; var maxIndex = 6; var x = 0; var y = 0; var timerInterval = 100; // milliseconds var xPos = null; var yPos = null; function moveBlock() { if ( index < 0 || index >= maxIndex || block === null || clockStep === null ) { self.clearInterval( clockStep ); return; } block.style.left = xPos[index] + "px"; block.style.top = yPos[index] + "px"; index++; } function onBlockClick( blockID ) { if ( clockStep !== null ) { return; } block = document.getElementById( blockID ); index = 0; x = number(block.style.left); // parseInt( block.style.left, 10 ); y = number(block.style.top); // parseInt( block.style.top, 10 ); xPos = new Array( x+10, x+20, x+30, x+40, x+50, x+60 ); yPos = new Array( y-10, y-20, y-30, y-40, y-50, y-60 ); clockStep = self.SetInterval( moveBlock(), timerInterval ); } --> </script> <style type="text/css" media="all"> <!-- @import url("styles.css"); #blockMenu { z-index: 0; width: 650px; height: 600px; background-color: blue; padding: 0; } #block1 { z-index: 30; position: relative; top: 10px; left: 10px; background-color: red; width: 200px; height: 200px; margin: 0; padding: 0; /* background-image: url("images/block1.png"); */ } #block2 { z-index: 30; position: relative; top: 50px; left: 220px; background-color: red; width: 200px; height: 200px; margin: 0; padding: 0; /* background-image: url("images/block1.png"); */ } #block3 { z-index: 30; position: relative; top: 50px; left: 440px; background-color: red; width: 200px; height: 200px; margin: 0; padding: 0; /* background-image: url("images/block1.png"); */ } #block4 { z-index: 30; position: relative; top: 0px; left: 600px; background-color: red; width: 200px; height: 200px; margin: 0; padding: 0; /* background-image: url("images/block1.png"); */ } #block1 a { display: block; width: 100%; height: 100%; } #block2 a { display: block; width: 100%; height: 100%; } #block3 a { display: block; width: 100%; height: 100%; } #block4 a { display: block; width: 100%; height: 100%; } #block1 a:hover { background-color: green; } #block2 a:hover { background-color: green; } #block3 a:hover { background-color: green; } #block4 a:hover { background-color: green; } #block1 a:active { background-color: yellow; } #block2 a:active { background-color: yellow; } #block3 a:active { background-color: yellow; } #block4 a:active { background-color: yellow; } --> </style>

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >