Using A Minus In Javascript

Dec 3, 2006

I have the following link to bring up an alert with a figure in it based on
the screen resolution. but instead of displaying a number 'NaN' is
displayed.

<a href="javascript:alert('Your ideal estimated height is '+
screen.height*0.55-screen.height*0.2);" class="BodyLink">Click to calculate
height </a>

But when I remove the part of the equation '-screen.height*0.2' a figure is
displayed properly. Why doesnt it work when I have a minus in the equation.
Im not experienced with javascript so excuse if this is a basic question..

View 19 Replies


ADVERTISEMENT

Passing Plus Or Minus As A Variable?

Dec 26, 2011

if I wanted to set a variable with radio buttons to decide whether a function adds or subtracts, I know I can't do this:

<body>
<input type="radio" name ="op" onclick="op='-'">count up: <input type="radio" name ="op" onclick="op='+'">
<script type="text/javascript">

[Code].....

View 13 Replies View Related

Check To Make Sure Number Isn't Minus

Jul 6, 2005

I have a form with about 15 input boxes. I need a function that will run onChange in each input box. This function has to check if a number is - or +. If it is -, I need it to throw out an error.

View 2 Replies View Related

Trigger Combination Of Ctrl + Minus

Oct 24, 2010

I need javascript to trigger the combination of ctrl + minus. Is it possible. I need this because the design of the webpage I'm working on is looking much better at 83 % zoom which couldn't be achieved by CSS zoom property in mozzila firefox.

View 2 Replies View Related

JQuery :: Select All Inputs That Have A Value Containing A Minus Sign?

May 29, 2010

I am so close to finishing this project and I stumbled upon this block...

<div class="line first">
<input type="text" value="0,00" class="nbr first">
<input type="text" value="" class="date">
<input type="text" value="" class="date2">

[Code]...

I have here two inputs with class nbr. The initial values are set, and those values change programmatically over time. My list of inputs is a lot longer than this but I simplified. You can see the work in progress on [URL]. Just insert two random dates in page1 with the datepicker and the navigation will appear. At the end of a series of calculation I need to grab all inputs with positive numbers, and all inputs with negative numbers.I was thinking of selecting all fields with nbr class first, then use .filter() with a function

edit: nevermind, I found it.

$('input.nbr.first').filter( function(){
if($(this).val().indexOf( "-" ) !== -1) {return true} else {return false}
} )

View 3 Replies View Related

JQuery :: Saving Chain Minus A Selector?

Feb 24, 2010

I've checked Google and searched the jQuery forum and didn't see anything. Is there a way to do the following as I'd like to use the same chain multiple times with with different selectors:

var chain = .attr('value', 'Search Digital Collections').css('color', '#E0E0E0');

View 2 Replies View Related

JQuery :: Classname Of Link Not Toggle Between Plus And Minus

May 10, 2010

I've just recently become enlightened by jQuery and would like to add it to my site, but I'm having a little trouble. I made this basic function:
function showPanel(id) {
var panel = $(".further_info." + id + "");
panel.slideToggle();
$(this).toggleClass("minus");
$(this).toggleClass("plus");
}

To give an example of its use:
<a class="panel_control plus" onclick="showPanel(0);"></a> <div class="further_info 0"></div>
The panel is displayed correctly, but the classname of the link isn't toggled between "plus" and "minus."

View 2 Replies View Related

Jquery :: Toggle Plus / Minus Image And Animate Photo

Jun 23, 2011

How to do this but still can't figure it out. I'm currently reading jQuery from novice to ninja but I'm no where close to a ninja. I have a div containing list items, a photo, and a plus/minus button at the bottom of the div. The list items are absolutely positioned behind the photo. When I click on the plus button I want it to change to minus and animate the photo 29px from the top revealing the list-items behind it. Then I want to click the minus button changing it back to plus and animating the photo back up to the top.

I'm trying to accomplish something very similar to what you see on Kyanmedia.com. Except their images animate down and up on hover. I want my image to animate down then up on click and toggle the plus/minus image. I'm new to jQuery so I'm having a real hard time trying to figure this out. Everything I've tried doesn't work. The links to Kyan Media to get an idea of what I'm trying to do.

View 1 Replies View Related

Swaps A Toggle Image For News For A Plus Or Minus Sign Showing If The Div Is Open Or Closed

Dec 11, 2009

I have this little snippet of code that swaps a toggle image for news for a plus or minus sign showing if the div is open or closed. This code has worked before but i made a couple modifications today and it stopped working unexpectedly and i'm not sure why its failing. I am presetting the div tag with a plus sign with css and then modifying it with javascript. The problem i am having is that when the div tag has been opened it does not swap the image to min.gif anylonger. It remains max.gif.

[Code]....

View 5 Replies View Related

Dynamically Writing Html/javascript From A Javascript Function

Jul 23, 2005

I'm working on some code and am running into brick walls. I'm trying
to write out Javascript with Javascript and I've read the clj Meta FAQ
and didn't see the answer, read many similar posts (with no luck
though), and searched through the IRT.ORG Faqs
(www.irt.org/script/script.htm).

The Javascript is designed to open an popup window and then inside that
window call another script which will resize that window. There may be
another way around this but the reason I tried this approach initially
was that I wanted to call the onload handler in the popup window to
resize the image only after the image had completely loaded. I've had
some code in the primary Javascript file (showimage.js) before that
works if the image has been cached but on the first load, it doesn't
resize properly which tells me it is probably because it is trying to
resize the window based on the image size but it isn't completely known
at that point. So I removed that code and tried placing the resizing
code in the second Javascript file (resizewindow.js). BTW I've tried
other code to open a popup image and automatically size it ie Q1443 at
irt.org but that doesn't do exactly what we need.

Even if there is another way to do this with one file, I still want to
figure out why this isn't working in case I run into it in the future.

I thought what I would need to do to use document.writeln to write
Javascript would be to escape any special characters and to break
apart the script tag ie

document.writeln('</SCRIPT>');

would become

document.writeln('</SCR' + 'IPT>');

I have a HTML page and 2 Javascript files. All files are in the same
directory and have permissions set correctly.

Here are the 3 files (keep in mind wordwrap has jacked up the
formatting):

index.html
----------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1"
SRC="showimage.js">
</SCRIPT>
</head>

<body>
Click the house<BR>
<A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG
SRC="house1thumb.jpg"></A>
</body>
</html>


showimage.js
------------
function newWindow1(pic,sitename)
{

picWindow=window.open('','','width=25,height=25,sc rollbars=1,resizable=1');
picWindow.document.writeln('<html> <head>');
picWindow.document.writeln('<SCR' + 'IPT type="text/javascript"
LANGUAGE="JavaScript1.1" SRC="resizewindow.js"></SCR' + 'IPT>');
picWindow.document.writeln('</head>');
picWindow.document.writeln('<body onload="resizewindow();">');
picWindow.document.writeln('<img src=' + pic + '>');
picWindow.document.writeln('</body> </html>');
picWindow.document.close();
}

resizewindow.js
---------------
function resizewindow()
{
// Do resizing here.
// Right now this isn't being executed
alert("resizing window");
}


Can anyone provide some pointers as to why this javascript is failing?
I'm using IE6 on Win2k and when I click on the image to open the popup
window, it does open the window but it is white with no content and the
system immediately goes from about 4% CPU usage to 100% and
consistently stays there until I kill that window with the task
manager.

View 9 Replies View Related

DOM Javascript - Imbed Javascript In Dynamically Added Row

Jul 23, 2005

Attached is a simple HTML file that adds and delete rows. In the add
row function I set an attribute "onClick" this triggers the
testMessage() function. When I try this in Firefox it works just fine
however on IE it just refuses to work.

What is interseting is the ROW that already exists has a similar
'onClick' event which works when the page is loaded, but subsequent
"row" additions to the table to not work in IE. Code:

View 9 Replies View Related

Text/javascript, Application/x-javascript, Difference?

Feb 19, 2007

two possibilities or the attribute type of script:

text/javascript (the one i usually use) application/x-javascript

what are the differencies between both?

depends on the html content?

for example html 4.0.1 versus xhtml 1.1?

View 12 Replies View Related

Javascript Function Has No Properties In Javascript Console

May 25, 2005

I'm getting errors in Firefox everytime I try to run this frame resize code, but it works fine in IE. I can't seem to figure out what the problem is with it.

The error is: Error: theFrame has no properties
Line: 8

The line that the javascript console is showing an error for is in italics.

code from page:

<html>
<head>
<script type="text/javascript">
var defaultCols="100px,*";
var hiddenCols="0px,*";
function ShowHideMenu(){
theFrame = document.getElementById("framed");
if(theFrame.cols == defaultCols) theFrame.cols=hiddenCols;
else theFrame.cols=defaultCols;
}
</script>
<frameset cols="100px,*" name="framed">
<frame src="lframe.htm" name="frameMenu">
<frame src="mframe.htm" name="content">
</frameset>
</head>
<body>
</body></html>

Come someone let me know what I'm doing wrong here?

View 2 Replies View Related

'Javascript Anthology' Or 'Professional Javascript For Web Developers'?

Mar 30, 2006

I'm already past the basics of Javascript, and i need something that takes me to the other level and teaches me the new technologies and cool stuff (drag&drop, AJAX, OOP in javascript, maybe XUL...etc). So far i found these two books:

1. Sitepoint's "The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks".
2. Worx's "Professional JavaScript for Web Developers (Wrox Professional Guides)"

Both seems to cover very insteresting topics, but i can only buy one of them. So which one do you suggest?

and by the way, i've read the sample chapter 5 of Sitepoint's book, and it seems like the author(s) just put the solutions/codes there and let you figure them out on your own. Is this how the rest of the chapters are?

View 3 Replies View Related

Nixing Javascript Via Javascript: Pseudoproto?

Jul 23, 2005

This is a question about defensive web browsing. Ocassionally I run into a page whose JavaScript does something that I find obnoxious. I would like to turn off JavaScript only for that page (instead of disabling it globally). It would be cool if there were some way to do this through a "bookmarkable" JavaScript snippet using the javascript: pseudoprotocol. Does anyone know any trick to do any of this?

View 2 Replies View Related

Extract Links From Javascript (not Using Javascript)?

May 26, 2006

I am looking for a method to extract the links embedded within the
Javascript in a web page: an ActiveX component, or example code in
C++/Pascal/etc. I am looking for a general solution, not one tailored
to a particular page/script.

Hopefully, the problem can be solved without recreating a complete
Javascript interpreter. Any ideas?

View 9 Replies View Related

Turn A Javascript Into A Javascript Function?

Oct 21, 2005

I have some javascript that I have written into the <body> section and it works great. But I would like to make it into a javascript function and define the function in the <head> section. Then in the <body> section write a small bit of javascript that would call the function() object. Code:

View 2 Replies View Related

How To Insert Javascript Code Within Javascript?

Jan 7, 2006

I would like to know how to write javascript such that, a part of it isnt considered as script, & rather as HTML. Code:

Ok, the layer div can be written using document.write. But, Google ad itself is a javascript isnt it. How can it be written into this? How does this work?

View 3 Replies View Related

AJAX, Eval(), And Javascript Within Javascript

Apr 28, 2006

Ok so, this is my purpose:
- to be able to load asynchronously (via AJAX) some javascript ads (like google's or adbrite) so as to make them be loaded in the background, then update the page after the ads have loaded via innerHTML

Why?
-Because 90% of the time in my newer sites, javascript ads are the major offender in terms of speed of page rendering

My problem:
Via ajax, I can call a php file that retrieves some javascript and outputs it, XMLhttprequest returns those javascript lines, but they don't render in the page, since they miss the whole page loading, and are apparently not parsed
For example, let's say I call a php file via ajax, and it returns the output into a variable named "text" containing "document.write('hello')"
if I use xxx.innerHTML=text, nothing happens

My 1st solution:
Passing those javascript lines to eval() [like eval(text) ], but this produces a second problem, that I couldn't solve (probably because of my lack of knowledge in javascipt):
if I eval the code, it deletes my current page and renders a new one
for example, if I parse a document.write, my page disappears, and a new one is rendered with the document.write text

What I want is basically to make that "document.write" appear inside a div in my page, adding to the content (and not overwriting the whole page), much like what happens when using innerHTML

Is this even possible? How would you go about it?
I tried xxx.innerHTML=eval(outputfromphpfile) but it overwrites my whole page...

View 3 Replies View Related

JavaScript Withing JavaScript ?

Nov 26, 2000

Just a quickie: is it possible to place javascript within javascript? The following is the code I am using to create a pop-up for a picture gallery. I would like to place a banner from a banner exchange in bold under each photo. When I use the code below I get an error message:

<SCRIPT language=JavaScript>
<!--
function openpic(pic_name) {
myWin= open("", "displayWindow", "width=640,height=510,status=no,toolbar=no,
menubar=no,scrollbars=yes,resizable=yes,alwaysraised=yes");

myWin.document.open();
myWin.document.write("<html><head><title>" + pic_name + "</title>");
myWin.document.write("</head><BODY><center><TABLE CELLPADDING=&#390;' CELLSPACING=&#390;' WIDTH=òr'>");
myWin.document.write("<br><img src=kate/image"+ pic_name + ".jpg><br>");
myWin.document.write("<br><br><BR><br><BR><br><BR>");
myWin.document.write("<script language='javascript' type='text/javascript' src='http://www.linkbuddies.com/ad.go?id=134039+2&n=3'></script>");

myWin.document.write("</center></body></html>");

myWin.document.close();
}

//-->
</SCRIPT>

View 16 Replies View Related

Javascript Inside Javascript

Dec 12, 2005

Basically, on one of my sites I'm running adsense and today I added Chitika. The problem is, I can't run those type of ads through my banner advertising program.

The banner advertising program calls the banners/HTML from code like this:

<script language=JavaScript src=http://www.mysite.com/advertise/abm.asp?z=1></script>

And using that program I'm able to either choose a banner or HTML I want to display when that code above is used. It displays HTML ok... but when I try to run an ad of either adsense or chitika nothing displays on the page. The code that would be called is:

<script type="text/javascript"><!--
*Chicika code in here*
//--></script>
<script src="http://xxx/xxx/mm.js" type="text/javascript">
</script>

So... it looks like I can't have javascript call another javascript to display on a page. My question is then... how can I edit the above to make it work or how can I work around this problem? I'd really want this to work with Chitika and not so much with adsense... but it appears both Chitika and Adsense use similar javascript code.

View 9 Replies View Related

Include Javascript File In Another Javascript File

Jul 26, 2006

is it possible to use functions from javascript file A.js in javascript file B.js?

View 5 Replies View Related

ASP Within Javascript

Jul 23, 2005

How can I pull this ASP var into javascript?
What is wrong with this statement?

<%
todaysdate = (now)
response.write (todaysdate)
%>
<script language="JavaScript"><!--
var date = new Date();
var aspdate = <%=todaysdate %>
document.write(aspdate);
//--></script>

View 4 Replies View Related

Javascript V ASP

Jul 23, 2005

does a client side script always need a server side script in order to
function?

how can i get my javascript application to send the details of a user
filled form to me without having to have a server side script?

if i have both server side and client side script in a web
application, will the resulting application run as a client or server?

i know i probably haven't made much sense, but the problem is that i'm
trying to make sense of it all.

View 3 Replies View Related

Javascript Ide

Jul 23, 2005

I'm looking for javascript IDE with code completition and preferably script debuging. Cross platform (Windows, Linux) would be a plus.

View 1 Replies View Related

Jsp Tag In Javascript

Jul 23, 2005

I have javascript function in my jsp page. Function does following :
text1 += '<xupdate:insert-before></xupdate:insert-before>;

but i get exception that <jsp:root> expected . Slash is a problem. I try
change it to &gt; but it does nothing. Is there other solution??

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved