Cannot Get Method Argument Passed As Function Parameter

Dec 1, 2011

New to JS. Have ordered some new books, but need to get somethings going in the mean time. What I wanted to do is to link to a new page having a date range input in the form of 6 text boxes, 2 sets of mm-dd-yy, from and to, where the upon loading the page box 1 of the from would auto focus and then auto tab and then post where php could take over on the server side. Setting up the form and the lay out, no problem. Auto focusing went just like expected using the following code, included because on the next step everything fell apart.

Code:
<script type="text/javascript" >
window.onload=function() {
document.getElementById("input1").focus();
}
</script>

So then the wheels came off and in response, began to simplify what was trying to be done to find where the issues were. As far as I can get working is:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL]">
<html>
<head>
<script type="text/javascript" >
window.onload=function() {
document.getElementById("input1").focus();
}
</script>
<script type="text/javascript" >
function myFunc() {
alert("is this working");
}
</script>
</head>
<body>
<input id="input1" name="input1" type="text" onkeyup="myFunc()" maxlength="2" value="type a No." />
</body>
</html>

First issue with this: When I first get to the page everything is just as ordered. The focus is on the text box and the default value is "type a No." When I press a key onkeyup, I bring up the alert box with "is this working" in it. But when I refresh the page with the refresh button, after clicking the "ok" on the alert box, the character that was typed in is still displayed. If I use the link to the page, or the URL from the address bar, then the page reloads properly with the default value, "type a No".

How do you get the default textbox value using the refresh button as apposed to reloading the page using a link or from the address bar? Using Firefox 8.0 more important at the moment: If I change the script to pass an argument to the function the script crashes. It does not pull up an alert box and freezes. My guess is that I'm doing something wrong on a concept level. Changed the default value of the text box to " ". Looked like to me there was an issue with the size specification and the default string length as you could only enter in a key stroke by highlighting the text and replacing it.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL]">
<html>
<head>
<script type="text/javascript" >
window.onload=function() {
document.getElementById("input1").focus();
}
</script>
<script type="text/javascript" >
function myFunc(awe) {
alert(awe);
}
</script>
</head>
<body>
<input id="input1" name="input1" type="text" onkeyup="myFunc("123")" maxlength="2" value="" />
</body>
</html>

View 1 Replies


ADVERTISEMENT

Cant Get Method Argument Passed To Function To Document.write

Dec 1, 2011

What I wanted to do is to link to a new page having a date range input in the form of 6 text boxes, 2 sets of mm-dd-yy, from and to, where the upon loading the page box 1 of the from would auto focus and then auto tab and then post where php could take over on the server side. Setting up the form and the lay out, no problem. Auto focusing went just like expected using the following code, included because on the next step everything fell apart.

[/CODE]
<script type="text/javascript" >
window.onload=function() {
document.getElementById("input1").focus();

[Code].....

View 3 Replies View Related

JQuery :: Using Ajax For Passed Argument To PHP Function?

Aug 3, 2011

How I use $.ajax() for passed argument to php function other file example index.php.

View 1 Replies View Related

Find The Average Of The Values In An Array Of Numbers Passed As Argument To A Function?

Apr 20, 2009

How do i use a function to find the average of the values in an array of numbers passed as argument to a function.(using java script) thank you for your help...

View 1 Replies View Related

Parameter MyDIVnode.firstChild.nodeValue Not Passed To Function

Oct 1, 2006

why this parameter is not passed to function ?

var myDIVnode1 = document.createElement("DIV");
// etc
myDIVnode1.appendChild(document.createTextNode("a"));
// this shows "a"
alert(myDIVnode1.firstChild.nodeValue);

myDIVnode1.onclick= function() { somefunc(myDIVnode.firstChild.nodeValue); };

function somefunc(param)
{
// this returns "undefined" !!??
alert(param);
}

View 4 Replies View Related

Simple Function Works But Then Stops Working Once Add An Argument / Parameter?

Apr 20, 2011

I have a simple function to display an image when called, but if I try to rewrite the function to take the image as an argument, it stops working.

works:

<html>
<script language="JavaScript">
var ImagePlusSign = '<img src="plus.jpg" name="slide" width="65" height="50"/>';

[code]...

View 3 Replies View Related

DOM Passed Through An Argument Executes Too Early?

Aug 21, 2011

This is a post relate to this post:DOM inside variable with innerHTML?To reduce any ambiguity this new thread deals with the code below.The previous post was more about how DOM can be used in a variable.This one has to do with a similar problem, but more with functions.

<html>
<head>
<title>Test</title>

[code]....

View 4 Replies View Related

JQuery :: Use "this" Event Which Has Been Passed To A Function As A Parameter?

Aug 11, 2009

I have a link;

<a href="javascript:{}" onclick="DoSomething(this)">click me</a> And what i'd like to do is use the "this" object to manipulate the css of its parent;

function DoSomething(obj) {
if(obj) {
$(obj).parent.addClass("newstyle");[code]...

Does anyone know how to do this with jquery?

View 2 Replies View Related

Passing A Function As An Argument And Using The Evaluated Functionas An Argument

Nov 30, 2006

how to you use the result of a function as the argument for another function instead of passing the actual function to it. i.e.

function foo2(){}

function foo(func){}

foo(foo2);

This passes foo2 to foo, can I do foo(foo2()) ? i.e. is the difference between whether a function is passed or evaluated dependent on whether you use "()" after the function name?

View 1 Replies View Related

Change Img Src With Passed Html Parameter?

Feb 1, 2010

I have downloaded 2 html pages that give me page1 with a drop down box for a list, and a 'show' button. this then passes dropdown value to page2 and JS presents the text on the page, but I want to use the passed parameter to change the src of an img with ID=img1.can post all the JS if you like but assume i am missing just a one liner replacing the ....

var name = getValue("name");
document.write(name);

View 4 Replies View Related

XML Document Passed As Jsp Parameter In Javascript Ok With Mozilla, Not In IE!!

Sep 27, 2007

I have a strange problem... I have a form with a text area that contains an XML document. This document can be modified by the user.

Once the document has been modified, the user pressed the "Submit" button to submit the modification (onclick=modify())... and go to another jsp page.... in my javascript, I have the following code:

function modify()
{
myRand=parseInt(Math.random()*99999999); // cache buster
var docXML=document.forms[0].xml.value;
var plist="myRand="+myRand+"&docXML="+escape(docXML);
url="modify_xml.jsp?"+plist;
document.forms[0].action=url;
document.forms[0].submit();
}


With Firefox, the problem does not occur.... but with Explorer, the form is not even submitted!!!!! Is there a workaround for this? The XML document is not even very big.

View 7 Replies View Related

Jquery :: Syntax To Use ID Passed In Parameter Refer To DIV

Dec 24, 2009

I'm passing the id of a div as a parameter. I'm not sure how to refer to it with Jquery. The following does not work:
Code:
function updatemail(param1, param2) {
$("#param2").animate({ opacity: "show" }, 300);
}
I also tried $(param2) but it did not work.

View 2 Replies View Related

Redirect A User To Another Page While Keeping The Passed In #parameter?

Aug 20, 2009

I posted a similar thread about this in the .NET forum, but I thought maybe there was a javascript way of doing what I need to do.Is there a way to redirect a user to another page while keeping the passed in #parameter?For example, if the user clicks the link:

page1.html#event1

Can I redirect to:

page2.html#event1

Basically keeping the #parameter in tact?

View 1 Replies View Related

JQuery :: Matching Passed Parameter To Image Map Areas

Aug 23, 2010

I am trying to match a passed parameter on a url to an area on an image map. So far I can find the correct area using
Code:
$('#mediummap area').each(function(i){
href = $(this).attr('href');
if (href == id) {
alert('Found ID ' + id);
}});}});

But next I need to retrieve the co-ordinates for the Area. I have tried
Code:
coords = $('this').attr('coords');
And
Code:
coords = $('this').coords();

I can not seem to get the value back, just an undefined return. What I want to do is to find the point on the image map and then centre that point with in the viewport for the image (large image, small viewport).

View 1 Replies View Related

Invalid Argument On Window Open Method

Mar 24, 2009

<a href="##" onclick="window.open('/Calendar/new.cfm','New Appointment','toolbar=0,height=800,width=850')" style="text-decoration:none; ">New</a>
I try to run this and I get an error saying invalid argument. I thought at first that maybe because the page is in a frame that it throws the error but I ran it outside of the frame and it still doesn't work. It works in FireFox though. Unfortunately I need it to work in IE 8.

View 2 Replies View Related

JQuery :: Parameter / Method For Positioning Thickbox?

Jun 23, 2009

Is there a parameter or method for positioning thickbox? The center of the page is usually ideal, but not always. I assumed something like this would work, but it doesn't seem to have any affect.

View 1 Replies View Related

Pass Checkbox Status To Jave Method As Parameter

Feb 23, 2009

I've one checkbox,I need to capture the status of this checkbox(i.e checked is "true" and unchecked is "false") to the java method as parameter.

I've check box like this

Code:

Javascript to get the status of check box like this..

Code:

I need to pass the return value of the javascript to the java method in command link action like thiss.

Code:

View 2 Replies View Related

Ajax :: Client Object Method Invoking With Parameter?

Dec 14, 2010

Inside client control I generate a button, with script to run.I want to call object's Print() method when this button is clicked, the result value must be passed to Print() as well.How can I do that?This is my object:

Type.registerNamespace("CustomControls");
CustomControls.FirstObj = function(element) {
CustomControls.FirstObj.initializeBase(this, [element]);[code]....

View 1 Replies View Related

Passing Replace Function As An Argument Of User Defined Function?

Jul 12, 2011

I am facing a problem in passing replace() function as an argument in user defined java function.

intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '' to '\'

I am posting my javascript function here:

<a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\/g,"\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a>
function OpenDocPreview(url, docname) {
alert('message from search base : ' + url + ' ' + docname);
}

View 1 Replies View Related

Replace Function As An Argument Of User Defined Function?

Jul 12, 2011

I am facing a problem in passing replace() function as an argument in user defined java function

intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '' to '\'

I am posting my javascript function here:

<a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\/g,"\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a>
function OpenDocPreview(url, docname) {
alert('message from search base : ' + url + ' ' + docname);
}

View 4 Replies View Related

Pass Checkbox Status To Jave Method As Parameter - Checked Is True And Unchecked Is False

Feb 23, 2009

I've one checkbox,I need to capture the status of this checkbox(i.e checked is "true" and unchecked is "false") to the java method as parameter.

I've check box like this

code:

Javascript to get the status of check box like this..

I need to pass the return value of the javascript to the java method in command link action like thiss.

View 1 Replies View Related

How Do You Pass An Argument To A Function

Mar 14, 2002

How do you pass an argument to a function.


for example if you have a <span id = "test" onMouseOver ="myfunc(x)>

eg you have lots of differant span id's but you want then all to have a certain background-color with each individual on mouseover event without having to write separate code for each span id
eg <span id=" test2"onmouseover ="this.style.background ='red'>....

View 1 Replies View Related

Nothing Is Being Passed Into The Function When It's Being Called?

Jul 31, 2011

I've come across functions like the one below in many scripts.I just don't understand the purpose of the parameter! Nothing is being passed into the function when it's being called- so what's the point of specifying an argument???

function doSomething(e) {
if (!e) var e = window.event;
alert(e.type);[code].....

View 8 Replies View Related

ID Not Being Passed To Function Undefined

Jul 9, 2009

I am making a drop down menu in javascript using a function in an external js file. Problem is in FF error console it keeps coming up that my ID that's being called in getElementByID in the function is not defined. Please help if you can, why is saying my ID is undefined??

View 2 Replies View Related

Cant Use Passed Variables In Function

Oct 11, 2010

I'm trying to reuse a script I have but, I'm not able to due to the fact I can't use some variables in a function.

I would like to know why I am not able to use passed variables in javascript.

For example: I call a function submit_data( 'newDomainForm', 'add_domain', 'list_div' ), in the function itself I would like to use the form name (first variable passed) as document.form.domain_name.value.

Later on I would like to use the div id: list_div in document.getElementById( div_id ).innerHTML. This doesn't work.

I have to put the name of the actual div like this: document.getElementById( 'result' ).innerHTML

And to get the value of a form element I have to put the actual name like this:

HTML Code:

View 9 Replies View Related

How To Reference Variable Through Function Argument?

Jun 9, 2007

How can I modify any one of these global variable identified via a function
argument?

var x1 = "bla";
var x2 = "bla";
var x3 = "bla";

function modify(variable) {

???? [variable]???? = "blabla":

}

The following onclick should change the string value of variable 'x1' from
"bla" to "blabla", via the above modify() function.

<a ... onclick="modify('x1')">

View 8 Replies View Related







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