simple code, but something is missing - JavaScript Help


While trying to run very simple code of javascript from within PHP, it runs when the code is:
My header ; alert('here I am');
Posted On: Wednesday 2nd of January 2013 12:00:46 AM Total Views:  45
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




Urgent help needed !!!

I have a probelem - how to save information as a txt or js file and retrieve it later using only html or javascript .
VIEWS ON THIS POST

168

Posted on:

Monday 19th November 2012
View Replies!

Image Mouseover Popup window help!

, I've attached my mouseover javascript to this, I have a problem with when the window initially pops up. when I put my mouseover the thumbnail, the window would pop up outside to the left of the screen, then when I move the mouse a little more it would come to the middle and function normally, it's just annoying. Help! This post has been edited by wintech: 06 November 2010 - 03:50 PM
VIEWS ON THIS POST

113

Posted on:

Wednesday 21st November 2012
View Replies!

Modify CoDrop's interactive twitter map for #hashtags instead of u

http://tympanus.net/...ive-google-map/ ! I am new to javascript & apis. I saw this cool open source code and I want to be able to edit it. Instead of placing twitter users on a map, I want to place tweets with a specific hashtag. Any advice
VIEWS ON THIS POST

134

Posted on:

Wednesday 21st November 2012
View Replies!

'Depth First Search' Maze Generating problem

, I'm having a problem with a Javascript maze generator. When I run it works, however the mazes being generated are not perfect as the depth first search algorithm should be, all the spaces are filled however you cant get into to some of the places within the maze meaning it is not perfect. I'm using Raphael to draw my SVG, I have attached a zip file of the files needed to run. Thank you in advance! Here is the code: //A javascript depth-first search algorithm function mazeGenerator(rows,coloumns) { function init() { //Sets up varibles this.cellSize = [5,5]; this.current = [0,0] this.cells = Array() this.cells[current] = false; this.traceback = Array(current); this.count = 0 //used to tell when all cells have been visted this.running = true } function makeGrid() { //creats the grid of cells for (var row=0;row
VIEWS ON THIS POST

93

Posted on:

Wednesday 21st November 2012
View Replies!

Format : [LastName, FirstName MiddleInitial.] Regular Expression

I hate regular expressions, I have to say that. Anyway, I want to create a regular expression that checks if a string has this format: [FirstName], [LastName] [MiddleInitial]. I tried doing it like this : /\w+, \w+ [a-zA-Z]\./.test(this.value) failure. Can help
VIEWS ON THIS POST

92

Posted on:

Wednesday 21st November 2012
View Replies!

Drop-down box validation

function creditType(x, min){ var uInput = x.value; if(uInput.length == min ){ return true; }else{ alert("Please enter " +min+ " characters"); x.focus(); return false; } } Credit Card Number: Card Type: Gold Card Washington Mutual American Express How would I do validations to make sure that the first number for Gold card is a 1, the first number for washington mutal is a 2, and the first number for american express is a 9.
VIEWS ON THIS POST

114

Posted on:

Wednesday 21st November 2012
View Replies!

Named anchors in IE

I am putting the following source anchor code but cannot get the expected results in Internet Explorer. Content Destination anchor code: please help out.
VIEWS ON THIS POST

80

Posted on:

Wednesday 21st November 2012
View Replies!

i need quick help

Hi in my code i used if statment (age must between 16 and 90) but it dose not work could you please correct the code for me function validateForm(contact) { var alphaExp = /^[0-9]+$/; var alphaExp2 = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/; if(""==document.forms.contact.Age.value) { alert("Please enter your Age."); return false; } if((!document.forms.contact.Age.value
VIEWS ON THIS POST

178

Posted on:

Wednesday 21st November 2012
View Replies!

Fractal Index In NinjaTrader

I am trying to insert a code block into the custom indicator wizard at Ninjatrader. They use C#. I've found a code block for what I want that produces eSignal's fractal index, I think they use javascript, and it inserts OK except for only 6 "expects ;" errors which I can fix. But at the end of this block, it gives an "expects statement" error. What ending statement goes there\t Will this revise the javascript version to Ninjascript OK The last part of the code looks like this: function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 or later.", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "error"); drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "upgrade"); return b; } else { b = true; } return b; } Ninjatrader's Ninjascript expects a closing statement right after the last "}" - What the heck is it The whole code is here "http://forum.esignalcentral.com/showthread.phpthreadid=22092
VIEWS ON THIS POST

90

Posted on:

Wednesday 21st November 2012
View Replies!

image enlargment

I am a total novice at javascript, just looking at it so I can introduce it into my webpage. The site stock exchange has this feature whereby you roll over an image and a popup window appears with the image as a larger size, which disappears when mouse is no longer over it. Looking at their source, they appear to be using somthing called showtrail. How is this function used Is it just a case of me doing onmouseover="showtrail(300,226,'smallImage.jpg');" onmouseout="hidetrail();"> Any advise or a better way of doing this would be great. cheers
VIEWS ON THIS POST

134

Posted on:

Wednesday 21st November 2012
View Replies!

Button to loose focus after close of popup window

Good day, I need help. I have an html button that calls & open another browser window on the onmouseup event, but once I close the popup new browser window my button has focus & is like selected. I want it not to be selected or clicked or has focus, how do i loose the focus after close of popup window onmouseup="window.open(" Please Assist!
VIEWS ON THIS POST

212

Posted on:

Wednesday 21st November 2012
View Replies!

connecting up external js and flash files

hi ive been trying to make up a little site that has a flash banner and one page links to an external javascript file for validation (its a contact form so all the fields require validation) if i use the forms are validated correctly and if i just use AC_AX_RunContent( 'width','900','height','100','src','banner.swf','movie','banner.swf' ); //end AC code the flash banner displays correctly at the top of the page however if i try and combine the two: AC_AX_RunContent( 'width','900','height','100','src','banner.swf','movie','banner.swf' ); //end AC code the validtion still works but my banner doesnt appear, can anyone shed any light on this for me please
VIEWS ON THIS POST

128

Posted on:

Wednesday 21st November 2012
View Replies!

show ip fail

I'm trying to show the ip on my homepage. I'm using some javascript but it won't work :S the code: var IPAddress = ''; document.write("Title Bar Display, Your IP is: "+IPAddress+""); window.defaultStatus = "Status Bar Display, Your IP is: "+IPAddress; alert("Alert Box, Your IP is: "+IPAddress); But his happend. The alert box pops up. And this is the text in the box: Alert Box, Your IP is: that's just not what I want. What's the problem with the code I've googles around and I got this error for all the codes i've seen. Please help!
VIEWS ON THIS POST

95

Posted on:

Wednesday 21st November 2012
View Replies!

POP-UP?

again, Here is my dilemma; I have a field on my form (asp.net 1.1 C#) that displays a helpdesk ticket number. What I want to do is: when a button is pressed, find this field on the form, then compare that field to a field in another table and if they match I want to open a pop-up window with the information from the help desk ticket associated to that particular form, and user. If the field is blank or has N/A an alert window should open. Here is what I have so far, but the button isn't firing\t I have no idea why. Could someone please take a look and help me out This is what I have in the of my html page: function OpenNewWin() { for(var i = 0; i
VIEWS ON THIS POST

64

Posted on:

Wednesday 21st November 2012
View Replies!

Attaching Javascript file to HTML how to

, I'm building my first website with JQuery/Javascript and I cannot for the life of me figure out how to get the javascript file to link together with the html file. Right now all I'm doing is stuff from a book so all the code in there is from a book, but for some reason, even if I do the simplest of javascript stuff it does not transfer over to my HTML file. Any thoughts here is my html code... New Web Project $35.99 $44.99 $35.99 $31.99 $40.49 $40.49 And javascript file... /*************************************** =IMAGE CAROUSEL -------------------------------------- */ $(document).ready(function() { var spacing = 140; function createControl(src) { return $('') .attr('src', src) .addClass('control') .css('opacity', 0.6) .css('display', 'none'); } var $leftRollover = createControl('images/left.gif'); var $rightRollover = createControl('images/right.gif'); var $enlargeRollover = createControl('images/enlarge.gif'); var $enlargedCover = $('') .addClass('enlarged') .hide() .appendTo('body'); var $closeButton = createControl('images/close.gif') .addClass('enlarged-control') .appendTo('body'); var $priceBadge = $('') .addClass('enlarged-price') .css('opacity', 0.6) .css('display', 'none') .appendTo('body'); var $waitThrobber = $('') .attr('src', 'images/wait.gif') .addClass('control') .css('z-index', 4) .hide(); $('#featured-books').css({ 'width': spacing * 3, 'height': '166px', 'overflow': 'hidden' }).find('.covers a').css({ 'float': 'none', 'position': 'absolute', 'left': 1000 }); var setUpCovers = function() { var $covers = $('#featured-books .covers a'); $covers.unbind('click').unbind('mouseover').unbind('mouseout'); // Left image; scroll right (to view images on left) when clicked. $covers.eq(0).css('left', 0).click(function(event) { $covers.eq(0).animate({'left': spacing}, 'fast'); $covers.eq(1).animate({'left': spacing * 2}, 'fast'); $covers.eq(2).animate({'left': spacing * 3}, 'fast'); $covers.eq($covers.length - 1).css('left', -spacing) .animate({'left': 0}, 'fast', function() { $(this).prependTo('#featured-books .covers'); setUpCovers(); }); event.preventDefault(); }).hover(function() { $leftRollover.appendTo(this).show(); }, function() { $leftRollover.hide(); }); // Right image; scroll left (to view images on right) when clicked. $covers.eq(2).css('left', spacing * 2).click(function(event) { $covers.eq(0).animate({'left': -spacing}, 'fast', function() { $(this).appendTo('#featured-books .covers'); setUpCovers(); }); $covers.eq(1).animate({'left': 0}, 'fast'); $covers.eq(2).animate({'left': spacing}, 'fast'); $covers.eq(3).css('left', spacing * 3).animate({ 'left': spacing * 2}, 'fast'); event.preventDefault(); }).hover(function() { $rightRollover.appendTo(this).show(); }, function() { $rightRollover.hide(); }); // Center image; enlarge cover when clicked. $covers.eq(1).css('left', spacing).click(function(event) { $waitThrobber.appendTo(this).show(); var price = $(this).find('.price').text(); var element = $(this).find('img').get(0); var coverLeft = 0; var coverTop = 0; var coverWidth = element.width; var coverHeight = element.height; while (element.offsetParent) { coverLeft += element.offsetLeft; coverTop += element.offsetTop; element = element.offsetParent; } $enlargedCover.attr('src', $(this).attr('href')).css({ 'left': coverLeft, 'top' : coverTop, 'width': coverWidth, 'height': coverHeight }); var animateEnlarge = function() { $waitThrobber.hide(); $enlargedCover.animate({ 'left': ($('body').width() - coverWidth * 3) / 2, 'top' : 100, 'width': coverWidth * 3, 'height': coverHeight * 3 }, 'normal', function() { $enlargedCover.one('click', function() { $closeButton.unbind('click').hide(); $priceBadge.hide(); $enlargedCover.fadeOut(); }); $closeButton.css({ 'left': ($('body').width() - coverWidth * 3) / 2, 'top' : 100 }).click(function() { $enlargedCover.click(); }).show(); $priceBadge.css({ 'right': ($('body').width() - coverWidth * 3) / 2, 'top' : 100 }).text(price).show(); }); }; if ($enlargedCover[0].complete) { animateEnlarge(); } else { $enlargedCover.bind('load', animateEnlarge); } event.preventDefault(); }).hover(function() { $enlargeRollover.appendTo(this).show(); }, function() { $enlargeRollover.hide(); }); }; setUpCovers(); }); and css file... body { } #featured-books { position: relative; background: #ddd; width: 440px; height: 186px; overflow: scroll; margin: 1em auto; padding: 0; text-align: center; z-index: 2; } #featured-books .covers { position: relative; width: 840px; z-index: 1; } #featured-books a { float: left; margin: 10px; height: 146px; } #featured-books .price { display: none; } Cheers Everyone
VIEWS ON THIS POST

95

Posted on:

Wednesday 21st November 2012
View Replies!

hw help

This is what i am trying to do: write a script that asks the user to enter two numbers, obtain the two numbers from the user and ouputs text that displays the sum, difference, product, quotient, modulas of the two numbers. This is what i have so far: Solution 6.16 Click Refresh (or Reload) to run the script again ** Edit **
VIEWS ON THIS POST

184

Posted on:

Thursday 22nd November 2012
View Replies!

ajax run 2 scripts?

I have the following code which works fine and runs the php script to send data to a mysql db. new Ajax.Updater( 'updateDiv', 'sendSpaResults.php', { asynchronous:true, method:'post', parameters: params } ); How can I also run formmail.cgi to send ...
VIEWS ON THIS POST

145

Posted on:

Thursday 22nd November 2012
View Replies!

POSTing data to PHP through Javascript Button

I ordinarily submit data to my PHP script through a POST action that redirects the page, but I'd like to get Javascript to handle that so I stay on the same page.
VIEWS ON THIS POST

128

Posted on:

Saturday 24th November 2012
View Replies!

Problems with getElementById()

It makes since that, when working with javascript, document.getElementById() can't find the Id of an object that hasn't yet been added to the DOM, however when I nest document.getElementById() in a function and call it after the object has been created, document.getElementById() still can't find the object. is there a way around this if not, can someone at least explain to me why it doesn't work Thank You
VIEWS ON THIS POST

138

Posted on:

Saturday 24th November 2012
View Replies!

JQuery Username Validation

I'm new to JQuery and attempting to write a script to check username availability. My problem is that no matter what I type, I always get back "This username is already in use." JQuery source: $(document).ready(function() { jQuery.validator.addMethod("usernameCheck", function(username) { var isSuccess = false; $.ajax({ url: "username_availability.php", data: "username=" + username, async: false, success: function(msg) { isSuccess = msg === "TRUE" true : false } }); return isSuccess; },""); $("#register_form").validate({ onkeyup:false, rules: { username: { required: true, minlength: 3, usernameCheck: true // remote check for duplicate username } }, messages: { username: { required: "username is required.", minlength: jQuery.format("username must be at least {0} characters in length."), usernameCheck: "This username is already in use." } } }); PHP Source: include('database_connection.php'); if (isset($_POST['username'])) { $username = mysql_real_escape_string($_POST['username']); $check_for_username = mysql_query("SELECT user_id FROM users WHERE username='$username'"); if (mysql_num_rows($check_for_username)) { echo "TRUE"; } else { echo "FALSE"; //No Record Found - Username is available } } > HTML Source:  
VIEWS ON THIS POST

103

Posted on:

Saturday 24th November 2012
View Replies!

dynamic HTML table - Highlighting 3 best rows from?

Guys, I have a dynamic HTML table which gets populated by coldfusion and displayed in the page, I have a column called performace which holds numeric values. I need to select the top 3 best performace value in the column and then highlight the entire row in different colours (top 3 values for performance). Can any one help me in doing it My server can run only Javascript and coldfusion, No Ajax/PHP. I need a complete set of code which such that I will add the script and it performs the calculating and highlighting part. Appreciate for a faster and a completed coding response :-) !!!
VIEWS ON THIS POST

104

Posted on:

Saturday 24th November 2012
View Replies!

javascript: how to retrieve file from cache?

I'm sending out AJAX request for a XML file to plot a chart. The problem is everytime the response comes back, the chart refresh itself, even if the XML is exactly the same. I would like to use Javascript to check the content of the reponse XML with the cached XML, and only push to the chart if there are changes, dont do anything if it's the same. How do I retrieve the cached XML
VIEWS ON THIS POST

119

Posted on:

Saturday 24th November 2012
View Replies!

Javascript game

I'm trying to make a javascript game which counts mouse click for ten seconds. The problem is that the script ignores the onclick event somehow.Here is the code. var c=0; var t; var timer_is_on=0; function timedCount() { document.getElementById('but').value=c; c=c+1; t=setTimeout("timedCount()",1000); if (c>10) {alert('over'); c=0;} } function doTimer() { if (!timer_is_on) { timer_is_on=1; timedCount(); } } function broi() { var count=0; document.getElementById('pole').value=count; count=count+1; } document.onclick=broi;
VIEWS ON THIS POST

208

Posted on:

Saturday 24th November 2012
View Replies!

Determine Name or ID of Select

Hi , This should be an easy one. I am using a single OnChange event with several statements, and need to identify the specific control that fired off the onchange event. I'm certain there must be a way to grab the ID or Name from the specific control in the javascript function, but I haven't been able to find it. Any thoughts
VIEWS ON THIS POST

72

Posted on:

Saturday 24th November 2012
View Replies!

Pop up window using JQuery

i am doing an application like a Form builder.. I am having a design page where i am generating the Fields using JQuery and displaying them each in a Div in the Preview panel of the same page. In my code i am saving all the Fields in the Form by iterating through all the Divs in the Preview panel. Now i want to add a functionality to show all the Divs in the preview panel in a pop - up window like when i click the Save Form button it must show all those DIvs in the Preview panel in the Window like a Preview and then it has to save the Form . How to include the Preview option in the Code also to show the preview in a pop-up window.\t My code to save the Form is like $("#fb_contentarea_col1down21 div").each(function() { var checked="false"; var id=$(this).attr("id"); //var fname=$("#label"+id+"").text(); var fsize=$("#input"+id+"").width(); var ftype=$("#input"+id+"").attr('data-attr'); var finstr=$("#instr"+id+"").text(); var fname=$("#label"+id+"").clone().html().replace(/ 0) { checked="true"; } $.ajax({ type: "POST", url: "http://localhost/FormBuilder/index.php/forms/saveField", data: "sequence_no="+id+"&name="+fname+"&type="+ftype+"&size="+fsize+"&instr="+finstr+"&formid="+getformid+"&required="+checked, success: function(msg){ //alert( "Data Saved: " + msg); }//success });//ajax });//Loop My fb_contentarea_col1down21 has all the Divs showing all the Fields of my Form. I am iterating through it and saving all the Fields. How to make all these to show like a preview in a pop-up window using JQuery....
VIEWS ON THIS POST

82

Posted on:

Saturday 24th November 2012
View Replies!

Parcer XML with AJAX

hi im trying to parce a XML that is generated by a php page, the problem is that when i try to get the elements on that XML, the browser says that my variables (dado) are undefined.... any idea how to solve this function leValorXML(xmldoc, tag){ var dado = xmldoc.getElementsByTagName(tag); var valor=""; if (browser.nav){ dado[0].hasChildNodes()===true valor=dado[0].firstChild.nodeValue : valor=""; }else{ dado[0].hasChildNodes()===true valor=dado[0].childNodes[0].nodeValue : valor=""; } return valor; }
VIEWS ON THIS POST

73

Posted on:

Saturday 24th November 2012
View Replies!

javascript confirm() function problem????

Hi Everyone, I am using javascript code for removing some records. When i am click on delete selected button. I want this should demand one confirm button in which i want if we click OK in confirm box then the record should be removed from database and if i will click on CANCEL button then it should not be removed that record. I have used some code for this but in this case when i click on CANCEL button after that this is also removing records that i does not want. So i am sending code for javascript which i am using for this. Please help me what code i should use for this application. here is code which i am using:---- function validate() { var confirmMessage="Are you sure to Delete these Details from Database ! " ; if(confirm(confirmMessage)==false) { return false; } } and this is delete button which i am using in my code: Please help me what javascript code i should use for this. It is very urgent for me.
VIEWS ON THIS POST

198

Posted on:

Saturday 24th November 2012
View Replies!

how to use escape and unescape

I don't know if this is your problem, but be nice to your browser -- quote your attribute properties. I'm thinking it should look more like this... Question: So what is this +s+ following the name attribute and in the showMAName function arguments If it's supposed to be a javascript variable, is this line supposed to be being written with a javascript write() because that piece of information sure would come in handy to solving your problem If it's not a javascript variable then what is it exactly And if it is a javascript variable but not generated with a javascript write() then your html element is not getting that data. If you clarify your situation I will try to help you more Otherwise escape() and unescape() work as prescribed. :-)
VIEWS ON THIS POST

92

Posted on:

Saturday 24th November 2012
View Replies!

list of event types for listeners?

Does anyone know where I can find a complete list of DOM/DHTML event types documented I'm trying to learn more about advanced event handling in JavaScript and I'd like to find lists of event types that I can attach/add event listeners to. I've been searching around and I've found a few resources, but nothing that seems complete. Here's what I've found so far:W3C: http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings MDC: https://developer.mozilla.org/En/DOM/Event.type MSDN: http://msdn.microsoft.com/en-us/library/ms533022(VS.85).aspx#unknown_1 quirksmode: http://www.quirksmode.org/dom/events/index.html Thank you. -- Ghodmode http://www.ghodmode.com
VIEWS ON THIS POST

146

Posted on:

Saturday 24th November 2012
View Replies!

restrict source view

hai .................. hey anybody got i dea abt how to restrict the user from viewing the JS source .......... pls help
VIEWS ON THIS POST

112

Posted on:

Saturday 24th November 2012
View Replies!

Making web site fill browser screen

I'm modifying a template using Dreamweaver that I downloaded from the web and I would like it to check the browser resolution and resize accordingly. It was designed at 1024x768 and looks OK at that resolution, but is someone is running 1280x1024 it is small on the screen. Does anyone know how I can do this I am using CSS so if someone can tell me if it is something I change in the CSS file or the .dwt template, then I can post the code and hopefully someone can assist Unfortunately, I am not very au fait with CSS and am just learning how to modify rather than write
VIEWS ON THIS POST

85

Posted on:

Saturday 24th November 2012
View Replies!

Rss, php, javascript nightmare! help?

> what the hell is wrong You should be the one telling us that. I would be surprised if something like this post even got answered. Just telling that things _don't_ work isn't helpful for anyone. That all being said, you should at least find out if this problem is a PHP one or a Javascript one, post the exact nature of the problem, the expected output and the output you are getting. Plus posting a code with no indentation is an instant repellant. Try isolating the cause of problem and if it's a PHP one, re-frame the question and post it in the PHP forums., so much for syntax highlight, i wrapped that last in code & inlinecode, nothing in the xml file its staying blank. heres the link to the code. http://support.invisionfree.com/index.phpshowtopic=443244&st=0entry10866133 Im thinking its the file host ripway. maybe theres a better one thats not complicated, accepts php and xml files and gives direct links I tried the awardspace host but its very complicated, i couldnt set it up right.
VIEWS ON THIS POST

101

Posted on:

Saturday 24th November 2012
View Replies!

FAVOURITE & HOME ICON on WEB PAGE

Hi all, How I can show the Home Icon and Favorite Icon on the Web Page. Please Also Tell me about the Slider in which I put the Home and Favorite Icon so anyone can make my website as their homepage or favorite page easily.
VIEWS ON THIS POST

79

Posted on:

Sunday 25th November 2012
View Replies!

How do I display database driven web links on pages.

I am working on a iPad flip book project. Using html c# Jquery Ajax and Javascript sql server database I have access all the data in the database to display the books base on client ID. The book works fine the problem is I have web links or page links that goes on each page. I using ajax and to retrieve the value which works. The problem I am having is wiring the links to the proper page. I can pull the links when I add them to the pages. Only the links of the odd pages are wired. but are wire to both pages. Example on page one. When page loads it does an ajax post if there are any links on page one return those links and wire them on page one. Then page two ajax post get links for page two and wire them on page two. right now it wire page one link to page one and two. When I turn the page it wires page three links to page three and four and so on. Here is my code: design page first Jquery, ajax and javascript code: var ContentCached = 1; // The is var CurrentPage = 1; var Contents = new Array(); var HotLinks = new Array(); var links = 0; var mask = 0; var OrgHeight; var OrgWidth; var Orientation = "portrait"; var doubleOrSingle = 'double'; var ResizeTimer; var Resizing = false; var timer = null; var LinkOverlayImg; var timeoutID; var timeoutIDFromButton; var DirectPage = false; //Number of times the links have blinked var linkBorderBlinked = 0; var timerCount = 0 var DirectPage = false; function TimerForLinks() { //If the link has not been blinked //then blinkit // if (linkBorderBlinked == 0) { // linkBorderBlinked = 1; $(".imgLink").css("background-image", "url(" + LinkOverlayImg + ")"); // } else { // linkBorderBlinked = 0; // $(".imgLink").css("background-image", "url(books/images/transparent.gif)"); // } // timerCount++; // if (timerCount > 5) { //after five blinks, stop the // //timer // clearInterval(timeoutIDFromButton); // clearInterval(timeoutID); // timerCount = 0; // linkBorderBlinked = 1; // } } //Starts the timer function BlinkLinks() { clearInterval(timeoutID); timeoutID = setInterval(TimerForLinks, 1000); } //Fills the conents array with the address of images from the server //it calls a page method GetUnloadedContent, passes to it the //book id that it gets form the query string function FillContentsArray() { $.ajax({ type: "POST", //Ajax type post url: "tabletBook.aspx/GetUnloadedContent", //URL plus Pagemethod call data: "{'bookid': '" + BookID + "'}", // bookid contentType: "application/json; charset=utf-8", //This is required or you will get all sorts of strange things :-) dataType: "json", //We need to specifiy JSON as to have the AJAX serilize the data between Client and server success: function (msg) { // The msg that comes back has in it the d attribute which in this case contains an array from the server Contents = msg.d; //Lets copy the passed back array to a global array $.ajax({ // Now since we got here , we call another page method which will get is the Original Page width and hieght - *****This is very Important, we need this for the Resize Calculations******** type: "POST", //Post url: "tabletBook.aspx/GetWidthHeight", //URL Pluse pagemethod data: "{'bookid': '" + BookID + "'}", //BookId contentType: "application/json; charset=utf-8", //Need this as above dataType: "json", //See above success: function (msg) { //The msg here will return an array that has 2 values , the width and height OrgWidth = msg.d[0]; //Lets save the values in globals OrgHeight = msg.d[1]; // Now we proceed with the rest of the page build GetPageContent(); //This function will Get and load the first page of content ResizeME(); // We call resize me here to resize the intail page to match the ipad screen PrecacheContent(); // Call to this function will start precaching the image } }); } }); } //Pre caches Images and that were passed in in the contents array //This could probably be done a more AJAX fashion, This function will //Eat up CPU Cycles, so for very large books expect it to be slow function PrecacheContent() { //Check if we still need to pull down images if (ContentCached < Contents.length) { $("").load(function () { // if so , then create a temp image object and Bind to the load function //Once the load function executes that means the image is done loading //Lets get it and set it to the correct page $("#Page-" + (ContentCached).toString()).css("background-image", "url('" + Contents[ContentCached] + "'),"); // images is loading $("#Page-" + (ContentCached).toString()).prepend($("").addClass("loadPic")); //Lets add the class loaded to it so we can indicate that it is loaded and need not to be pulled again $("#Page-" + (ContentCached).toString()).addClass("loaded"); //Since the book pages are set as the background image lets size them to 100% $("#Page-" + (ContentCached).toString()).css("background-size", "100% 100%"); //Since the page is loaded , lets make sure it is visible $("#Page-" + (ContentCached).toString()).show(); //increase the ContentCahced by one ContentCached = ContentCached + 1; //Call Precache content again until all images are loaded // PrecacheContent(); $('.loadPic').remove(); return; }).attr("src", Contents[ContentCached]); //set the url of the temp image to the content image } return; //Make sure to return } //Gets the first page, this can be modified to show a loader image like on the desktop books, once the image loads //then it can be hidden and the page shown (Just a thought) function GetPageContent() { if (CurrentPage == 0) { //If Current page is 0 //Get it and set the background to the iamge $("#Page-" + (CurrentPage).toString()).css("background-image", "url('" + Contents[CurrentPage] + "')"); $("#Page-" + (ContentCached).toString()).prepend($("").addClass("loadPic")); $("#Page-" + (CurrentPage).toString()).fadeIn("fast"); //Show the page $("#Page-" + (CurrentPage).toString()).addClass("loaded"); // set it to loaded $("#Page-" + (CurrentPage).toString()).css("background-size", "100% 100%"); //Fix the size $("#Page-" + (CurrentPage)).show(); $('.loadPic').remove(); } else { //The is left empty on purpose } } //This function gets called by window resize and by orientation change events //it will get the window height and 95 percent of the width //it will continue to loop untill we get a good hieght and width function ResizeME() { var winH100prc = $(window).height(); //Get the window hieght var winW95prc = .95 * $(window).width(); // Get 95% of the window width var bookHeight = winH100prc - 50; //set the book height to the window height - 50 pixels while (true) { // Keep looping until we get a good size var PageWidth; if (Orientation == "portrait") { // if we are in protriat mode Height > Widht PageWidth = winW95prc - 50; // the Page width is 50 px less then the window width } else { //if landscape , we need room for 2 pages PageWidth = winW95prc / 2; // the page width is the 95% of window width /2 } var ratio = PageWidth / OrgWidth; // lets get a change ratio by dividing the current page width by the original page width var newHieght = OrgHeight * ratio; // lets get the new height if ((newHieght) > bookHeight) { // if the height is still off the page winW95prc = winW95prc - 50; // subtract 50 pixels and loop continue; } else {//othereise , set the size of the book $("#book").turn("size", winW95prc, newHieght); $("#book").turn("resize"); //Call the resize method to resize all book elements break; //exit the loop } } } //Bind to the window resize function , some times the IPAD or mobile browser //will call the resize function instead of Orientation change $(window).resize(function () { if (!Resizing) { //We set a flag here so we need to do this once, Resize events on all browser fire many times persecond, //Which will cause you to lose sleep trying to figure it out. ResizeTimer = setTimeout(function () { // lets set a time out for one second before we resize anything if ($(window).width() > $(window).height()) { // if the window width is greater then window height Orientation = "landscape"; // we are in landscape mode $("#book").turn("display", 'double'); //set the book to display double pages $("#book").turn("resize"); // resize the book to fit } else { //we are in portrait mode Orientation = "portrait" $("#book").turn("display", 'single'); //Set the book to single page $("#book").turn("resize"); //Reize the book } ResizeME(); //Call the resize function to make certain the images get resized clearTimeout(ResizeTimer); //Clear the timer flag Resizing = false; //reset the size flag }, 1200); } }); //Binding to the orientationchange event , this event will //fire an unknown number of times when the device changes orientation //it is unknown because each browser, implements this event //Differently $(window).bind("orientationchange", function (e) { $("#BookContainer").fadeOut(); //lets fade out the book if (!Resizing) { //if the resizing flag is false //set the resize timer ResizeTimer = setTimeout(function () {// lets set a time out for one second before we resize anything if ($(window).width() > $(window).height()) { Orientation = "landscape"; //same as above $("#book").turn("display", 'double'); //same as above $("#book").turn("resize"); //same as above $("#book").bind("turned", function (e, page) { var v = $("#book").turn("view"); $("#CView").val(v[0] + " - " + v[1]).css({ 'text-align': 'center' }); CurrentPage = page; }); } else { Orientation = "portrait"//same as above $("#book").turn("display", 'single'); //same as above $("#book").turn("resize"); //same as above $("#book").bind("turned", function (e, page) { var v = $("#book").turn("view"); $("#CView").val(v[0]).css({ 'text-align': 'center' }); CurrentPage = page; }); } ResizeME(); //same as above $("#BookContainer").fadeIn(); //Fade the book in clearTimeout(ResizeTimer); Resizing = false; }, 1200); } }); //Bind to the window load event, once all screen assets have //loaded, you may init the book and begin to load the image $(window).load(function () { //Get images from server and fill content array FillContentsArray(); //Lets check if we started landscape or portrait //set the display correctly if ($(window).width() > $(window).height()) { Orientation = "landscape"; doubleOrSingle = "double" } else { Orientation = "portrait"; doubleOrSingle = "single"; } //Events for buttons $("#btnRight").bind("tap", function (e, page) { $("#book").turn("next"); }); // click left button turn previouse $("#btnLeft").bind("tap", function (e, page) { $("#book").turn("previous"); }); //swipe page from edge of page left $(window).bind("swipeleft", function (e, page) { $("#book").turn("next"); }); //swipe page from edge of page right $(window).bind("swiperight", function (e, page) { $("#book").turn("previous"); }); //Stops Page current location $("#btnAutoStop").bind("tap", function (e, page) { clearInterval(timer); }); //Go the First Pages $("#btnFirst").bind("tap", function (e, page) { $("#book").turn("page", 1) }) $("#book").bind("zoom.doubleTap", function (event) { if ($(this).zoom("value") == 0) { $(this).zomm("zoomIn", event); } else { $(this).zoom("zoomOut"); } }); //Goto the Last Pages $("#btnLast").bind("tap", function (e, page) { // pages = Contents.length; $("#book").turn("page", $("#book").turn("pages")); }); //Call the turn js plugin $("#book").turn({ acceleration: true, display: doubleOrSingle, inclination: 0, duration: 650, peel: 'br' } ); //This function is called when the pages are turned $("#btnAutoPlay").click(function () { Play(); }); $("#book").bind("turning", function (e, page) { //Check if the page is loaded for both left and right //If not loaded load the page and then display if (!$("#Page-" + (page - 1).toString()).hasClass("loaded")) {//If not show a loader image (You may have to tweak this) $("#Page-" + (page - 1).toString()).prepend($('').addClass("ShowLoading")); $("#Page-" + (page - 1).toString()).css("background-image", "url('" + Contents[page - 1] + "')") $("#Page-" + (page - 1).toString()).addClass("loaded"); $("#Page-" + (page - 1).toString()).fadeIn("fast", function () { $(".ShowLoading").remove(); $("#Page-" + (page - 1).toString()).remove(".ShowLoading"); }); $("#Page-" + (page - 1).toString()).css("background-size", "100% 100%"); } else { $("#Page-" + (page).toString()).show(); } if (!$("#Page-" + (page).toString()).hasClass("loaded")) { $("#Page-" + (page).toString()).prepend($('').addClass("ShowLoading")); $("#Page-" + (page).toString()).css("background-image", "url('" + Contents[page] + "')") $("#Page-" + (page).toString()).addClass("loaded"); $("#Page-" + (page).toString()).fadeIn("fast", function () { $(".ShowLoading").remove(); $("#Page-" + (page).toString()).remove(".ShowLoading"); }); $("#Page-" + (page).toString()).css("background-size", "100% 100%"); } else { } }); //This function is called as you start to turn the page, it will load the new page form //the contents array, this is where you would pull links via an ajax call //you dont draw them here though $("#book").bind("start", function (e, page) { $("#Page-" + page.page).css("background-image", "url('" + Contents[page.page] + "')"); $("#Page-" + (page.page).toString()).css("background-size", "100% 100%"); $("#Page-" + page.next).css("background-image", "url('" + Contents[page.next] + "')"); $("#Page-" + (page.next).toString()).css("background-size", "100% 100%"); LinkLoading(BookID, page.page); LinkLoading(BookID, page.next); }); // Once the page has been completed turned , display the page numbers in the header or what ever //you want to do after the page has turned, this could be where //you would draw your links posts, or what ever other assets you want to display $("#book").bind("turned", function (e, page) { $(".imgLink").remove(); var v = $("#book").turn("view"); $("#CView").val(v[0]).css({ 'text-align': 'center' }); $("#pgDiv" + (page - 1).toString()).remove(); $("#Page-" + (page - 1).toString()).css("background-size", "100% 100%").append(HotLinks); $("#pgDiv" + (page).toString()).remove(); $("#Page-" + (page).toString()).css("background-size", "100% 100%").append(HotLinks); BlinkLinks(); }); //When the book first loads it calls this event //it basiclly gets called every time the book //reaches page one $("#book").bind("first", function (e) { CurrentPage = 0; GetPageContent(); }); //we need an inital size for the book $("#book").css("width", "100px"); $("#book").css("height", "100px"); ResizeME(); // Call resize to get the correct sizes //remember by this time in the execution, your assets are loaded $("#book").fadeIn("fast"); // Show the book LinkLoading(BookID, CurrentPage); }); $(".imgLink").live("mouseover", function () { $(this).css("background-image", "url(" + LinkOverlayImg + ")"); $(this).css("cursor", "pointer"); }); $(".imgLink").live("mouseout", function () { $(this).css("background-image", "url(books/images/transparent.gif)"); }); $(".imgLink").live("tap", function (e, page) { var LinkType = $(this).attr("linkType"); if (LinkType.toUpperCase() == "WEB") { var href = $(this).attr("title"); window.open(href, "_blank"); } else if (LinkType.toUpperCase() == "DIRECTPAGE") { var pgLink = $(this).attr("title"); $("#book").turn("page", parseInt(pgLink)); } else if (LinkType.toUpperCase() == "IMAGELINK") { href = $(this).attr("title"); } else if (LinkType.toUpperCase() == "VIDEOLINK") { //video link } }); //When the doc is ready , show a loader image, for some add reason I cant get it to display, I will //leave it for you to figure out $(document).ready(function () { $(loaderImage).prepend("#book").prepend($('').addClass("ShowLoading")); BookID = getParameterByName("bookid"); //Get the query string param that has the book Id CurrentPage = 0; //set the current page to zero $(".Showloading").remove(); }); function Play() { timer = setInterval(function (e, page) { var way = 1; if (way == 1) { $("#book").turn("next"); } }, 1650); } // Ajax call to get the hot links from the database and return function LinkLoading(BookID, page) { //Starting code for the search for links $.ajax({ type: "POST", // AJAX type post url: "tabletbook.aspx/GetPageLinks", data: '{"BookID": "' + BookID + '", "page": "' + page + '"}', contentType: "application/json; charset=utf-8", //This is required or you will get all sorts of strange things :-) dataType: "json", //We need to specifiy JSON as to have the AJAX serilize the data between Client and server success: function (link) { // The msg that comes back has in it the d attribute which in this case contains an array from the server HotLinks = link.d; //Lets copy the links to a global array $.ajax({ type: "POST", url: "tabletbook.aspx/GetLinkOverImage", data: '{"BookID": "' + BookID + '"}', contentType: "application/json; charset=utf-8", //This is required or you will get all sorts of strange things :-) dataType: "json", //We need to specifiy JSON as to have the AJAX serilize the data between Client and server success: function (ret) { LinkOverlayImg = ret.d; } }); } }); } C# with web method code: [WebMethod(true)] public static string[] GetUnloadedContent(int bookid) { try { DCPages dcPages = new DCPages(); List CurrentPages = dcPages.GetBookPages(bookid); StringBuilder sb = new StringBuilder(); int cpn = 1; List UnloadedImages = new List(); foreach (FlipBookPage p in CurrentPages) { string s = p.PageContent.Substring(1); UnloadedImages.Add(s); } return UnloadedImages.ToArray(); } catch (Exception ex) { return null; } } [WebMethod(true)] public static string[] GetWidthHeight(int bookid) { FlipBook Book; DCBook DCB = new DCBook(); Book = DCB.Getbook(bookid); double width = Book.OrigWidth; double height = Book.OrigHeight; List Dems = new List(); Dems.Add(width.ToString()); Dems.Add(height.ToString()); return Dems.ToArray(); } [WebMethod(true)] public static string GetPageLinks(int BookID, int page) { if (page < 1) { return ""; } //Lets call the database and get the links for this book bookLinksDC bldc = new bookLinksDC(); List hotlinks = new List(); // hot spot links book hotlinks = bldc.GetPageLinks(BookID, page.ToString()); string ret = ""; //If we have links if (hotlinks.Count > 0) { foreach (BookLink hotlink in hotlinks) { //The rectangle is created with some attributes //id is the letter M and the name of the file //Class is imgLink - this so it can act like an HTML anchor tag and also PageNo1 //PageNo is the words "PageNo and the number of the current page (Page-1,Page-2,Page-3,etc,etc,etc) //Make sure to set the style to absolute position and border is 0, set the background to a transparent gif //which will make the div invisible, and still allow the use of the mouse events //if you set the DIV to invisible it will not respond to mouse events string rect = ""; rect = rect + "";//Close off the div ret = ret + rect; } return ret; } else { return ""; } } [WebMethod(true)] public static string GetLinkOverImage(int BookID) { BookDC bdc = new BookDC(); string s = bdc.GetOverlayImage(BookID); if (String.IsNullOrEmpty(s)) { s = "/books/images/linkOverlay.png"; } return s; } protected void Page_Load(object sender, EventArgs e) { int bookid = int.Parse(Request.QueryString["bookid"]); //hidbookID.InnerHtml = bookid.ToString(); string ClientID; //Current Client ID DCPages dcPages = new DCPages(); int width = 612; int height = 768; try { List CurrentPages = dcPages.GetBookPages(bookid); StringBuilder sb = new StringBuilder(); int cpn = 0; // foreach (FlipBookPage p in CurrentPages) { sb.AppendLine(""); cpn++; } BookDC BDC = new BookDC(); //Get the current book object FlipBook id = BDC.GetBook(bookid); ClientID = id.ClientID.ToString(); ClientDC cdc = new ClientDC(); string clientName = cdc.GetClientName(id.ClientID); string BookClientTitle = clientName + " " + id.BookTitle; //this.bookTitle.InnerText = BookClientTitle; this.bookTitle1.InnerText = BookClientTitle; book.InnerHtml = sb.ToString(); } catch (Exception ex) { } }
VIEWS ON THIS POST

104

Posted on:

Monday 26th November 2012
View Replies!

javascript and gridviews

User enters integer values into an editable gridview. JS is meant to keep a running total in the gridview footer template while user enters the values. User clicks 'Save' button. The values are saved to database table. Problems: 1. JS does not keep a running total if there is already values saved in a database table. (Explaination: If user clicks 'select all', the previously added values are loaded. Can edit these and running total works. But, if user is entering numbers for the first time into a blank editable gridview, the js does not work). 2. Cannot access label in gridview footer template. 'Object reference not set to an instance of an object'. If label is placed in normal gridview row, it is fine. However, it needs to be in the footer. javascript function var sumVal = Number(0); function sum(id1,id2) { var current = document.getElementById(id1).value; sumVal += Number(current); document.getElementById(id2).innerText = sumVal; } javascript snippet from gridview_rowdatabound //Javascript controls TextBox numbers = (TextBox)e.Row.FindControl("NumberTextBox"); numbers.Attributes.Clear(); //Meant to be in footer template but placed in normal row for now Label total = (Label)e.Row.FindControl("total"); total.Attributes.Clear(); //Sums up the values of each textbox numbers.Attributes.Add("onblur", string.Format("sum('{0}', '{1}')", numbers.ClientID, total.ClientID ));
VIEWS ON THIS POST

67

Posted on:

Monday 26th November 2012
View Replies!

Saving A File To The Hard Drive

I am working on a project in which I will have to generate a .html file and save it to the user's hard drive. Please help me.
VIEWS ON THIS POST

84

Posted on:

Monday 26th November 2012
View Replies!

Div Shadows and Background Gradient with Jquery

Hi Can you please let me know where I can find a demo or example of JQuery Plugin which let's to create a Div with shadows(Inner and Drop shadows) and plugin to add gradient to Div background color Best
VIEWS ON THIS POST

129

Posted on:

Monday 26th November 2012
View Replies!

get the last character of string with javascript

I had a difficult time figuring out how to get or test the last character of a string with javascript, so figured I would post it once I found out in case it helps someone else. I found plenty of removing the last character, but not for just checking what the last character of a string is using javascript. // create string var str = new String("No Periods owed."); // alternatively get string from field: // var str = document.getElementById('textbox').value; // show last character in the string alert( str.charAt( str.length-1 ) ); // remove last character from string if a period if(str.charAt( str.length-1 ) == ".") { alert( str.slice(0, -1) ); } Well, finding that easily on a search would have saved me some time. Happy Coding!
VIEWS ON THIS POST

82

Posted on:

Monday 26th November 2012
View Replies!

Pop Up Window - JavaScript Help

How to showPop Up when form is refreshed and on the back nothing will work hwo can do that .\t when form is refreshed form is working . how can do that plz send me the code if u have ...........
VIEWS ON THIS POST

90

Posted on:

Tuesday 27th November 2012
View Replies!

createElement not work

I'm trying to add new tags into document using createElement() function but this not work. Tested in FF2 and IE6. Simple example is here http://web.practisoft.cz/samples/jstest.html Buttons enclosed in first div are created in html code and work as expected. Buttons ...
VIEWS ON THIS POST

83

Posted on:

Friday 30th November 2012
View Replies!

How to update a label using Javascript?

In my asp.net 2.0 web application, I would like to display the process progress information in the browser. The progress info is displayed one after another with 1 or 2 seconds delay in between them. I believe you have ...
VIEWS ON THIS POST

180

Posted on:

Friday 30th November 2012
View Replies!

Change the src of an Iframe.

Hi ! I have the HTML source like this: And I tried to change the source of the iframe like this: document.frames.Content_IF.location.href = 'iframe.php'; or like this: document.Content_IF.location.href = 'iframe.php'; These 2 ways ...
VIEWS ON THIS POST

125

Posted on:

Friday 30th November 2012
View Replies!

setInterval and objects

On Nov 10, 3:58 pm, Jeff wrote: > I've been trying to pass in an object in a setInterval but it > complains about missing ] after elenment list. > > setInterval("someFunction("+some_object+")",1000); > > What's the correct syntax to ...
VIEWS ON THIS POST

119

Posted on:

Friday 30th November 2012
View Replies!

Contact form

I know its not the best idea to have a contact form in Javascript, but my PHP contact is not working where I have my clients site hosted (mezoka, they run php 5, but not phpmail().). Could someone possibly help me out, when I run my Javascript form, I dont get an email to my address when I test it. Contact