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


ADVERTISEMENT

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 View Related

Write A Simple Function That Locates A Parameter In Url?

Jan 21, 2009

I am trying to write a simple javascript function that locates a parameter in a url, if it is present, and replace it with a different value. Here's my code:

function setParam(url,param,value) {
var a = '&'+param+'=d+';
var new_url = url.replace(new RegExp(a), '');
new_url = new_url + '&'+param+'='+value;
return new_url;
}

The problem is, it doesn't work. It adds the new param, value pair to the old url, but the old param isn't replaced. What do I need to do here to make this work?

View 2 Replies View Related

JQuery :: .Each Function Stops Working?

Apr 14, 2010

I have a table with a SAVE button on each row (id=SaveBD)...but I also have aSAVE ALL button at the top. It works pretty good except the .each function seems torandomly stop near the end ofthe row countand not save all the rows.that would cause the rows to stop saving?

$(document).ready(function(){
$("#SaveAll").click( function(event){
$ ("#SaveAll").hide();

[code]....

View 1 Replies View Related

Check Row By Clicking Function Is On, The Checkbox Stops Working?

Dec 2, 2011

I'm trying to create a demo to display a new way of showing our data.I thought I remembered this being pretty simple but I'm hitting a snag. The table, the mouse over, and the check row by clicking on the row all work separately but when the check row by clicking function is on, seen in the first row, the checkbox stops working.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript"> [code]...........

View 2 Replies View Related

JQuery :: Body Click Function Stops Other Live Functions From Working?

Oct 26, 2010

When thebody section below iscommented out, I get hello, and when it isn't, I don't !

$("body"
).click(function
(e){
return

[Code]....

Is this a bug, is it an unavoidable aspect of the "live" architecture

View 3 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

Document.write("Goodbye!"); Stops Working When Placed Inside A Function?

Apr 16, 2011

document.write("Goodbye!");

works but I put ^ that inside a function

function SayHello ()
(
document.write("Goodbye!");
)

and it stops working? I know the function call works because when I place some code to display an image in SayHello function, it displays the image

View 2 Replies View Related

Simple Key Event Function Not Working ?

Jul 6, 2009

I have a simple function defined on my page in the script section that should put me in a div named "apDiv4" a text when i press the down arrow in a text input called 'search2'. But it does nothing.

Here's the function:

And here is where i call it:

Why this doesn't work? I've tried onkeydown= "KeyCheck()" too.

View 5 Replies View Related

Works In Firefox, Not In IE 'Invalid Argument'?

Sep 16, 2011

I had the following code in a page I was working on recently:

Code:
<tr><td><input type="button" id="larrow" value="<-----" onclick="doScroll(-1);"</td>
<td><input type="button" id="rarrow" value="----->" onclick="doScroll(1);"</td></tr>

[code]....

View 4 Replies View Related

Simple Echo OnClick Function Not Working

Jul 6, 2010

I am trying to do a simple echo onclick, but despite what I try to do, it shows no errors, but won't work. I've tried things like:
echo "<div onclick="alert('test');">t</div>";
echo '<div onclick="alert('test');">t</div>';
But just can't seem to get it to work right. I'm trying to do this on a script that is being eval on the ajax request. Thus I'm having problems placing the ',", marks.

View 7 Replies View Related

JQuery :: Simple Font Resize Function Not Working In IE

Apr 17, 2011

I have a simple font size function as follows which works fine across safari/firefox but does nothing in IE?[code]...

View 1 Replies View Related

Simple Hide - LightBox (Click Function Not Working)

Dec 17, 2010

This code doesn't work.
$('#lightBoxCloseButton').click(function() {
$('.css3Lightbox').hide();
});

View 1 Replies View Related

JQuery :: Form Plugin By Malsup Success Function Not Working On IE7 - Works On IE8

Oct 7, 2010

I'm trying to submit a form with the jQuery Form Plugin by malsup. I'm fairly positive my code is correct because in IE8 the success function is being called and the background of the boxes are turning green. In IE7 however, The submit function is definitely working as the file is uploaded to the correct place, but the success function is not being called/fired. Any ideas as to why this might be? Do IE7 and IE8 handle this that differently? The function in the success call is just changing a checkbox and combo box background colors to green.

View 1 Replies View Related

Script Stops Another From Working?

Nov 30, 2009

My website is all up and running and I decided to put a new image viewing script on, I already had a revolving image script showing all my previous work before but the latest script has totally stopped the previous from working. You can view what I mean at www.actioncomputing.co.uk

I am using 2 scripts both available on Dynamic Drive they are

Lightbox image viewer 2.03a Ultimate Fade-in slideshow (v2.1)

If anyone can tell me why this is I would be extremely gratefull.

View 7 Replies View Related

Ajax :: Stops Working In IE8 After Reload?

Jul 27, 2010

I have a simple function for an intranet site that should make and return a XMLHttpRequest object in most browsers (including IE8):

function createXMLHttpRequest() {
var xmlhttp = false;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();

[Code]....

Then I use it autocomplete a input text with a list of client company names from a database. Then the user selects a company and it reloads the page with that company's info. (The ajax input text box remains so the user can type in another company name)

In firefox this works fine. However, in IE8 the very first time the page loads it works fine, but after the user selects a company and the page reloads, the ajax longer works. It gives an error at "xmlhttp = new XMLHttpRequest();" saying: "Message: Object doesn't support this property or method"

If I type anything in the input, it gives the error: "Message: 'searchReq.readyState' is null or not an object" leading me to believe that somehow after the first time the page loads, IE is not able to process a XMLHttpRequest which seems unlikely, so I'm not sure where to go with my code. I've tried a bunch of other similar createXMLHttpRequest() functions, but they all have the same problem of working once then not working after.

View 1 Replies View Related

Script Null Parameter - It Works And Alerts 1, But That's Only If 'ifm' Is Set?

Aug 8, 2010

I'm trying to execute the following statement:

Code:
<script type='text/javascript'>
var value;
initEditor('tbMsg', true);[code]....

It works and alerts 1, but that's only if 'ifm' is set. If I were to take the above code and backspace out the i in ifm so it was fm, when I refresh my browser neither 1 or 2 gets alerted. Is this javascript's default behaviour, if so how can make it alert 2?

View 3 Replies View Related

JQuery :: Line Of JS Stops All Plugins Working?

Sep 1, 2010

WhenIrun the below code above the init code for jQuery plugins it stops them working. Im just trying to run the code after the DOM has loaded, is there a better way? <script type="text/javascript">$(document).ready(function() {

// The gallery is hidden so need to unhide it.
document.getElementById('verticalCarousel').style.visibility='visible'
})
</script>

View 4 Replies View Related

JQuery :: Animation Stops Working After First Click?

Apr 29, 2009

I have the following code

$('input.productSubmitInput').click(function() {
$('#login-info')
.animate( { backgroundColor:"#7AFB73" }, 500 )

[code]....

View 1 Replies View Related

Script Stops Working In No Conflict Mode

Jun 26, 2011

I have four scripts being called to my page however i have two that isn�t playing nicely. The two in question is Fancybox and the Nivo Slider. The slider and fancybox both work alone but not when they are on the same page, however the slider will stop working when

Code:

Is used and nothing changed when i apply it to Fancybox instead. I have tried wrapping and dividing the scripts with

Code:

But nothing. I have also changed all

Code:

To

Code:

On the slider but again no change.

Here are the scripts in my <head> :

Code:

The problem mostly is that the slider won�t work in no conflict mode but won�t work with Fancybox either.

View 2 Replies View Related

Stops Working When Fetching Data From MySQL?

Aug 3, 2011

I have my doubts if this question belongs to the javascript side since it's all good until the data from MySQL comes in, but since the javascript is the one breaking I'll take my chances.

The external js (portada.js)

Code:
$(document).ready(function(){
var currentPosition = 0;
var currentPosition2 = 0;
var currentPosition3 = 0;

[Code]....

As you can see I have three divs with different slideshows (slideshow, slideshow2 and slideshow3), they have products that slide to the left. When I was testing to make sure it all looks good the sliding feature was working fine, but I lost this feature when the data was being retrieved from MySQL (at the moment on <div class="slide">).

View 3 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

JQuery :: Cascade Stops Working On Latestes Version?

Jan 8, 2012

I'm trying to use the cascade function from the below link. If I try it as it is there, it works, but if I change the jquery reference to the one I'm using (1.7.1) it stops working... is there a diferent way to use that ajax call or am I missing anything?

View 3 Replies View Related

Ajax :: Multiple Calls Same Page Stops Working IE?

Aug 16, 2011

I have several ajax calls that originates from the same page its updating. It works perfectly in firefox but in IE it works for about 18 requests and then just stops until the page is refreshed. I thought it was a cashe issue but I have added a variable for that. I think it may have something to do with binding but I am not sure how to sort that. This is one of my functions.

[Code]....

View 3 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

JQuery :: Cycle Works In All Browsers Except IE: "Invalid Argument..."?

Sep 8, 2010

The cycle plugins works great inMozillabut when comes to IE 8 it shows up the above error.I have given the height as auto.But in chrome the image is cropped.Why could be that happened?The image rotates in chrome but its a portion is visible only.I am using J-query version - jquery-1.4.2.min.js and cycle version isjquery.cycle.all.2.74.js

View 8 Replies View Related







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