Multiple Arguments In Switch?

Jul 23, 2005

As I can remember this is not allowed in Java:

int x, y, z;
switch(x,y,z){
case 1,2,3:
System.out.println("Hep");
break;
}

But what about in JavaScript, or are there some other kind og syntax for switch?

View 2 Replies


ADVERTISEMENT

Switch Multiple Backgrounds On Mouseover

Mar 20, 2011

As a JS rookie I've managed to toggle specific backgrounds on multiple mouseovers. The code below does exactly what I want, but I'm not quite satisfied with the way it's done.The definite webpage will contain a lot of projectboxes, and for each project I need to add two functions in my script. Not very efficient. I'm looking for a single function which works in the same way, preferably making use of an array where I can add new projectimages.

View 1 Replies View Related

JQuery :: Toggle/Switch For Multiple Items?

Dec 29, 2009

I'm looking for a lightweight way to be able to switch between 2 divs on a page.

I have found various ways to do this online with jQuery, but none of which are able to handle multiple switches and make it extendable across the pages of my website efficiently.

For example I could have 12 - 15 individual elements on a page (All with same style) each with an option to switch content e.g. "Click here to do something" then once clicked "it would reveal something" (Within that element/<li> tag) - so it's element specific.

For example:

Code:
<ul>
<li class="box>
Title

[Code]....

But of course as it's element specific you have to associate each id together but you can't have two id="2" - as that won't validate.....

Looking around, a perfect example can be seen at: [URL]

And because it's CMS driven and will have multiple categories/pages, you can't list all the id's with the javascript, so it has to be portable/OOP (Is that the word?) so just a main identifier in the JS...??

Where you click to reveal code and it switches div, but only for that element, it doesn't effect anything else.

View 2 Replies View Related

Switch In Script With Multiple Values In Case?

Sep 23, 2008

I would like to do a switch in javascript, with multiple values in the case. code...

View 14 Replies View Related

Switch Case Detect For Multiple Values More Efficiently?

Sep 7, 2010

I know this does not work, but hopefully you can see what I am trying to do. Only the first value is tested, but I want all of them to be.

[Code]...

Pretend there are like 10 more cases with more numbers with them. Currently this will only text to see if x is 0 or 42. How do I get it to test for the other numbers?

View 7 Replies View Related

Mozilla: Not Enough Arguments

Jul 20, 2005

I embedded a javascript in HTML and tried to open the file using
mozilla 1.4 it gave me the following exception in the script on
clicking the Submit/Next button. IE was able to execute the script

Function defination
function evaluate(form)

Line making the call :
<INPUT onclick="if (validate(this.form)) evaluate(this.form);"
type=button value=Submit/Next name=B1>&nbsp;&nbsp;&nbsp;

Mozilla Javascript console window.

Error: uncaught exception: [Exception... "Not enough arguments
[nsIDOMXPathEvaluator.evaluate]" nsresult: "0x80570001
(NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: <unknown
filename> :: onclick :: line 0" data: no]

View 1 Replies View Related

AWM Menu - How To Get Different Arguments

Jun 28, 2010

I am using AWM menu and there is functon awmCreateMenu() which creates a menu, but exactly not getting the different arguments to this function. How to get meanings of these parameters? Actually I want to activate or open this menu using an short key like shift+MenuName first alphabet eg Shift + A or Alt + A will also do.

View 9 Replies View Related

Why The Output Is Not Arguments

Jul 2, 2010

function args() { return arguments; }args(); the reault is []?what's the "return arguments; meaning?

View 1 Replies View Related

Calling An Executable With Arguments

Jul 20, 2005

Is there anyway to call an executable on a local disk (W2K) with arguments
from javascript? Or from any other language for that matter?

We are trying to create a simple 'portal' page to a group of our c++
applications via a webbrowser. To open the applications however you must
pass them command line options.

View 2 Replies View Related

JQuery :: Use Variables As CSS Arguments?

Sep 9, 2010

I need to be able to pass a variable to a CSS argument after computing the size of the viewers window height. I am using an alert function to test it, but so far it won't populate.

$(document).ready(function() {
var winHeight = $(window).height();
var winWidth = $(window).width();

[Code]....

View 2 Replies View Related

Setting An Array As Arguments ?

Feb 15, 2010

I am a newbie and am writing a function. I want the function to refer to an arrays elements to get the biggest, but I dont know how to do this.

Here is the code:

what I am trying to do, is get the array elements to be called and give me an answer. Will I need to add the array to the function? It is further down the code after the function at the moment. Or will I need to add the array elements to the function?

View 4 Replies View Related

How To Pass Arguments To Function

Jan 9, 2011

I know in different languages (VB.Net,C++,C#) how to pass an argument to function in this code:
<html>
<head>
<script language="Javascript">
<!-- hide
function openNewWindow() {
popupWin = window.open('[URL]',
'open_window',
'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0')
} done hiding -->
</script></head><body>
<a href="javascript:openNewWindow();">return to front page</a>
</body></html>

I need to add several links in my page, so I need to pass indexes from links to main function, so I can open images in specific folder with indexes filenames. For example in vb
Subname("text_to_pass_to_SubName")
Public Sub SubName(ByVal function_text as string)
End Sub

View 8 Replies View Related

How To Get Parent Object Of Arguments

Aug 22, 2011

I have a setup where I need to get the function calling a function, which works fine, I just use arguments.callee.caller.Now I need to take it a step further and get the object that the function belongs too.
For example in a onclick="parentObj.someFunction()"
parentObj.someFunction calls some other function. I need a way to know that parentObj was involved, just getting someFunction isn't enough because parentObj has properties that are used in someFunction. To make it more interesting lets say I can't pass any more parameters to someFunction, so I can't pass parentObj into it as an argument.

View 1 Replies View Related

Accessing Javascript Arguments

Mar 4, 2001

Say I have a tag like this

<SCRIPT src="navbar.js?width=580"></SCRIPT>

This is just a very simplified example.

In my navbar.js file, how would I retrieve the arguments such as "width"?

ie

var width = /*?????*/;
document.write("<TABLE width="+width+">");

View 3 Replies View Related

Use Replace() With Quotes IN The Arguments?

Sep 15, 2011

I'm trying to replace an element's style on the fly like this

Code:

var sc = document.getElementById("someElement").innerHTML;
scorecard = sc.replace("class="thisclass"","style="width:"+width+"px;float:left;margin-top:"+topmargin+"px;"");

where width and topmargin are values that I calculated earlier.This works fine in all browsers except IE. The trouble, I'm quite sure, is with the escaped quotes " in the arguments of the replace() function.What this seems to be doing (in IE) is just just returning the same string sc, but with the quotes stripped off of "thisclass".

View 2 Replies View Related

Trigger A Function From Pop Up Window And Arguments

Aug 14, 2006

I have a main page that opens a pop up window when the user clicks a
link. The pop up window is a menu and when the user clicks the item, it
populates a form input element on the 'parent' window.

My question is: this new populated form element is the value that I use
to change a style.

onchange does not watch this form element because of getelementbyid, so
it doesn't trigger the function needed to change the style. onchange
works fine if I just manually input a value into the text box.

Any other way to fire the function off when the user picks their
selection from the pop-up window? I was thinking I could use
window.opener.function()? But how do I pass the form from the parent
window? From the pop up window, I don't use this.form, what do I
use?something like window.opener.form[0] ?

View 2 Replies View Related

Arguments Passed By Window.setInterval

Jan 6, 2007

I'm calling `setInterval(myfunc, 100);`.
That function receives one parameter which seems to be -3, 0, 3, 6 or 9.
This isn't a problem, but I'm wondering what it is. Does someone know?

Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.1) Gecko/20061204
Firefox/2.0.0.1

View 2 Replies View Related

JQuery :: Passing Arguments To Simplemodal ?

Nov 15, 2011

I have the following html for simplemodal

For the following html

Where {{term.pk}} is different for similar items. I want to pass the value of {{term}} to the code used by simple modal

How do I pass this parameter to my html code using simplemodal?

View 2 Replies View Related

Attaching Arguments With Window.open?

Jan 7, 2010

I'm a PHP developer that needs to user javascript to open a window prior to a _POST call.

PHP Code:
<title>test</title>
<SCRIPT language="JavaScript">
function newwindow()
{
var myForm = document.header;
var txtValue = myForm.txtUsername.value;
var txtFileName = "lost_logon.php";
[Code]....

I need the window.open to open a new window with arguments attached. For example is the username is bigbob the call should be lost_login.php&user=bigbob. How do I pass the argument?

View 4 Replies View Related

Call Two Functions With Arguments Using Onclick?

Oct 20, 2011

need to call two functions say func1(a,b) and func2()i used the following code. But only the first function works, second one not working

Code:
<input type="button" value="Start" onclick="func1('A','B');func2()">

View 2 Replies View Related

Pass Arguments To Event Handler?

Jun 19, 2009

I'm use prototype quite a lot for ajax calls, but have always used inline onclicks. I'm trying to be less obtrusive by creating event handlers/listeners.I used to do this with the aid of pHp to place arguments into the function (usually via 'while loop'):

<li><a href="#" onclick="dofunction(arg1,arg2);">item 1</a></li>
<li><a href="#" onclick="dofunction(arg1,arg2);">item 2</a></li>
<li><a href="#" onclick="dofunction(arg1,arg2);">item 3</a></li>

[code]....

View 8 Replies View Related

Function Arguments As A Form Element?

Jan 18, 2009

I tried a function like that

function (test) {
var a=document.form.test.value;
}

test is the name of text fields. I doesn't work (undeclared test variable)

View 1 Replies View Related

Javascript Function Passing Arguments.

Jul 19, 2001

What I want is a loop that will call the same function until it reaches a certain number (let's say 10). Then I want the function to take the parameter passed (the number) and use it in the function where ever you see a 1 below. Basically I want it to run on each element of the pub_name array and from the info gathered define a variable based on the number (example: display_pub_name_*). I have run some tests .....

View 3 Replies View Related

AddEventListener Accepting Functions With Arguments?

Jan 29, 2006

I am trying to create a script that will cover cross-browser limitations in adding event listeners to elements. I have found plenty of resources to add a listener but can't find any way of assigning a function containing arguments. Here is what I have so far:

/* Attach events regardless of browser */

function addEvent(obj, evType, fn)
{
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, false);
return true;
}
else if (obj.attachEvent)
{
var r = obj.attachEvent("on"+evType, fn);
return r;
}
else
{
return false;
}}

/* Contains all attachments to be made on page load */

function load()
{
item = document.getElementById('toggleControl');
addEvent(item, 'click', toggle);

item = document.getElementById('alertLink');
addEvent(item, 'click', runAlert);
}

/* Add event to page load and assign load() function */

addEvent(window, 'load', load);

The actual functions for toggle and runAlert are in a seperate .js file, but are standard functions. the problem is that I can't find a way to perform the equivalent of:

item = document.getElementById('toggleControl');
addEvent(item, 'click', toggle('toggleID'));

It simply does not work.

View 10 Replies View Related

How To Modify Javascript Function To Take More Arguments.

Jan 23, 2007

I have an external javascript file with certain attributes defined to open a file in new window, which I use for viewing maps. However I need to define different attributes for the height and width, as I want users to open video clips in smaller windows. What do I need to do? Code:

View 5 Replies View Related

Creating A Function With Optional Arguments

Jul 18, 2002

How can I create a function that takes optional arguments?

View 7 Replies View Related







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