Passing Parameters To An Unobtrusive Function?
Jul 10, 2007
I was reading through a book that talked about unobtrusive javascript, and it gave this example of how to trigger a function instead of using an inline onmouseover event handler.
document.getElementById("RandomElementId").onmouseover=RandomFunction;
I thought this would be cool, but I can't seem to find a way to pass parameters to the function this way. I assumed you just use RandomFunction(parameter1,parameter2); but no go.
Is there a different syntax for this, or does this technique forbid using parameters?
View 3 Replies
ADVERTISEMENT
Nov 12, 2009
I have a PHP page that dynamically generates table rows with input fields. A sample row looks like:
Code:
<tr id="row1">
<td><input type="button" name="remove_row1" id="remove_row1" value="X" /></td>
</tr>
I have a JavaScript function that I am attempting to attach to each of the input buttons:
Code:
// get all the input elements
var inputs = document.getElementsByTagName('input');
var delete_regex = new RegExp('remove_row');[code]...
But I would like to give it a parameter
Code: inputs[i].onclick = delete_row('row' + inputs[i].id.replace('remove_row', ''));
But doing the above just executes the function. What is the best way to do this?
View 2 Replies
View Related
Jul 5, 2006
Problem: I have two functions that send an AJAX call via an attached .js file (engine.js) and then deal with the response. My problem is this, the function can be called by any number of different triggers and needs to pass the data to a different element depending on which one calls it. These different triggers are produced via a repeating region created by Coldfusion. Each element that can get acted upon by "updateImgCount_response" is named "imgCount[recordID]" where "recordID" is a value inserted by coldfusion. This way each Element has a unique ID. Now I just need to know how to tack the "recordID" value returned as part of "obj" onto the 'imgCount' in document.getElementById() the updateImgCount_response function. Code:
View 1 Replies
View Related
Jan 30, 2009
function refreshWindow ()
{
if (xmlHTTP)
xmlHTTP = null;
[Code].....
View 1 Replies
View Related
Mar 11, 2010
I'm trying to pass parameters using the jquery's ajax function, but I end up with a "function undefined" error message when I try.
I had trouble finding simple examples of ajax passing parameters with jquery.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
[Code].....
View 1 Replies
View Related
Jul 27, 2011
I totally understand that in order to learn javascript I need to know how functions work, I understand the basics of passing in parameters and then calling the function with the values to maybe add something together etc I ve read countless articles about functions as well as books etc but I just dont get how they are used and when they should be used etc, the more advanced functions that have maybe 4 parameters and are doing different calculations and returning various values that get fired back into the script just totally confuses me.
What I would like to know is first of all how can I overcome this confusion and also any words of wisdom you may have. I will also add that I have no prior programming experience and have spent the last 2 months frequently hitting my head off a brick wall as I just cant understand javascript.
View 1 Replies
View Related
Sep 30, 2009
I'm passing the variables myTitle and myLink to form.php using javascript.
This is the way I'm doing it:
Code:
<a href='form.php?title=" + myTitle +"&link="+myLink+">Click me</a>
It's working great but sometimes myTitle and myLink contain the plus character (+). When this happens it's not passed. In the case of the title, it's just a problem of looks but in the case of the link, well, the link won't work without the character.
As an example if the title is: Laptop + Accessories What is passed is: Laptop Accessories
What can I do to pass also the plus character??
View 4 Replies
View Related
Nov 16, 2009
Does anyone know how to make the cycle function in jquery unobtrusive?
I've got the following code and when I disable javascript, I get a nasty long list of images :(
Jquery code:
Html code:
View 1 Replies
View Related
Nov 3, 2010
I am trying to create a basic unobtrusive form validation function but I am having some issues/questions. Basically I am checking if any of the form fields have <= 3 characters, and if they do so, then I make those fields' backgrounds and borders red. Also in the empty <span> tags I insert an error message. My issues/questions are:
#1: So when I say if (fieldVals<=3) this means that the errors should appear if the values are 1,2 or 3 characters long, right? It does not do that though, when I insert one character in any of the form fields the errors go away, but they should not, right?
#2: How do I cancel the form from submitting if errors are visible and vice versa? When I use the return false when errors are visible, the code does not even run. What is going on? return true does the same.
#3: When I use a submit button(type="submit") instead of just a button(type="button"), the code does not run? What am I doing wrong?
I am not trying to use this on a website, I am just trying to learn how to use unobtrusive javascript. That's why I am only checking for empty fields. If I learn how to do this first, later I will try to add email check, date check etc.
THE CODE:
View 12 Replies
View Related
Jul 23, 2005
I have a JavaScript function that receives an Array with words. This
Array can be gotten from a query to a DB using JSP.
The JavaScript function is executed when onFocus event occurs:
<input type='text' onFocus='myFunction(this.event, myArray);' />
myArray is declared as:
<script>
var myArray = new Array('j'habite', 'tu habites', 'il habite');
</script>
I want to tell javascript:
var myArray = myJSPArray;
Where myJSPArray is declared some where in the JSP document.
View 2 Replies
View Related
May 14, 2009
myfunction(a,b,c)
{
do something;
}
[Code]....
passing 1 variable containing 3 parameters?
View 2 Replies
View Related
Aug 22, 2000
i need to pass values from one page to the next after clicking next...how do i do this using parameters?
View 2 Replies
View Related
Jun 10, 2011
Say I have the following code:
And I want this code to print 21.
How should I implement the function Curry?
I tried intuitively:
But it didn't work.
View 6 Replies
View Related
Jun 7, 2010
I am new to JQuery and trying to post some parameters from an anchor tag. But only my 'site' parameter gets passed. Here is my code :
<a class="screenshot-link" href="#" site='dv2' num='1'>1</a>
$(
".screenshot-link").click(function () {
[code]....
View 6 Replies
View Related
Dec 1, 2010
I am passing parameters from one page (actually from a frame within a frameset) to another using Javascript. Typically the code is as follows, taking values from a Form.
parent.titleFrame.location="frm_right_demo_title.html?MyDateEvent.value='"+ytt+
"'&MyParam_spec.value='"+parent.mainFrame.document.forms.myForm.MyParam_spec.value+"'";
This has worked fine in all browsers including IE, Chrome and Firefox version 2.0.0.2.
However, I have now found that it doesn't work with Firefox version 3.6.12.
This is because when retrieving the parameters in the new loaded page, the character ' (quote) has been converted to %27 (percent twenty seven).
I can write code to replace %27 with the quote character. However, this is lengthy and time-consuming (as I need to have cyclic code as the javascript replace command seems to work only on the first occurrence within a string).
View 7 Replies
View Related
Dec 31, 2009
I am trying to grab firstname from the previous form page and pass it into my open window command.
<script type="text/javascript">
{
window.open("https://www.MyWebsite.com/Myform.html?firstname=getQueryStringVariable('firstname')")
}
</script>
The above does not come out properly, I get entire GetQueryString etc in the Target URL
What should the syntax be, I think I may also be using the wrong javascript command, I think it should be a FormRequest, hmm not really sure.
View 1 Replies
View Related
May 22, 2003
There are basically 4 fields in a form, being Name,Company,Email and Phone. I'm trying to use the ONBLUR event, on the email field, to then pass parameters to a JS function, which calls a PHP file, to insert a row into a MySQL db. I saw an example of how to do this, using a hidden field, possibly I need 3 hidden fields to pass the 3 parameters (value of fields) ?. Anyway, here is the code:
View 2 Replies
View Related
Mar 27, 2010
There is a website that allows unlimited voting for one of my friend's sons. Someone else has been automating the process because another person received 14,000 votes in about an hour.
So my question is: [url]
How can I pass a parameter at the above site so that it votes for the selected person (example - PJ Howell) without clicking the name and then hitting vote?
View 1 Replies
View Related
Apr 19, 2010
Let's use this html form as an example: [URL]
How could I pass the information in the text fields to a thank you page after user hits submit using javascript?
I was attempting to use this, but it's slightly different from what I'm trying to do: [URL]
This is filling in the text fields via parameters in the URL. I'm trying to pass what the user filled in to the next thank you page listed out to see what they filled in.
View 3 Replies
View Related
Feb 16, 2011
I cannot seem to get this code to work properly and I'm wondering if it's a simple error in usage.I have a html page that calls a PHP and refreshes a DIV section every 10 seconds. So far works like a charm...but now I want to add some parameters to pass to this script...
Code:
$(document).ready(function() {
$("#DTable").load("response_query.php");
var refreshId = setInterval(function()
[code]....
So I added the ?a=aaa,b=bbb,c=ccc, randval='+Math.random()); to the load section and then in my PHP script got the $_GET values . but nothing seems to get passed so I'm wondering whether I have used or incorrectly passes these parameters to the script.
View 2 Replies
View Related
Feb 12, 2003
When introducing custom functionality to HTML elements we either use existing attributes to pass configuration parameters (like beetle's fValidate (http://www.peterbailey.net/fValidate/)) or invent our own (like my Tooltips (http://www.vladdy.net/webdesign/ToolTips.html)). While this method is ok for small amount of configuration information, it is not that flexible (you need to edit DTD) and becomes combersome when large amount of configuration parameters is needed.
I figured a more convinient way is to use a CSS like string to pass configuration parameters:
<div myextension="parameter1: value1; parameter2-subparameter1: value2.1; parameter2-subparameter2: value2.2"> </div>
Then initialization routine would contain:
if(myExtensionParameters = divElement.getAttribute('myExtension'))
divElement.myExtension = new myExtensionObject(divElement,myExtensionParameters);
Definition of possible parameters and their values can be done using an array of regular expressions:
myExtensionParamDefenitions = new Array();
myExtensionParamDefenitions['choiceparameter'] = /^s*(value1a|value1b|value1c)s*$/;
myExtensionParamDefenitions['stringparameter'] = /^s*(w+)s*$/;
myExtensionParamDefenitions['integerparameter'] = /^s*(d+)s*$/;
Constructor for the myExtensionObject would containd a parseParameters function:
function myExtensionObject(divElement,myExtensionParameters)
{ this.params=new Array();
parseParameters(this.params,myExtensionParamDefenitions,myExtensionParameters);
//Verify parameter initialization, if you like
str=''
for(e in this.params) str+= e + ': ' + this.params[e] + '
'
alert(str);
//Do whatever you have to do...
}
Function parseParameters has the following code:
function parseParameters(object,definitions,parameters)
{ paramEntries = parameters.split('');
for(var i=0; i<paramEntries.length; i++)
{ paramEntry = paramEntries[i].split(':');
if(paramEntry.length == 2)
{ paramName = paramEntry[0].replace(/^s*([w-]+)s*$/,'$1');
if(definitions[paramName])
{ res = definitions[paramName].exec(paramEntry[1]);
if(res[1])
object[convertCSSName(paramName)] = res[1];
}
}
}
}
Where convertCSSName function converts CSS type name (background-image) to javascript name (backgroundImage)
function convertCSSName(cssName)
{ sn = cssName.split('-');
rs = sn[0];
for(var i=1; i<sn.length; i++)
rs += sn[i].replace(/^(w)(w*)$/,function(str,p1,p2,offset,s){return p1.toUpperCase() + p2;})
return rs;
}
As a result you have params array of myExtensionObject object populated with validated entries. Changes and expansion is done by simply editing myExtensionParamDefenitions array.
PS: The functions are coded more for clarity rather than for brevity - I'm certain there are ways to improve the implementation.
View 3 Replies
View Related
Jun 22, 2009
I have passed following parameters in ajax function
Its not working. when i test the same function in following way it runs fine.
Am i commiting any mistake in supplying variable?
View 1 Replies
View Related
Feb 16, 2011
When datepicker closes the calendar window I'd like to pass both the date and the id of the <input> tag in the code below. The documentation mentions 'this' but no info on how to use it or how to use 'inst'.
View 1 Replies
View Related
Sep 2, 2009
I have added an event listener to a LI item in the DOM:
liNode.addEventListener("mouseover", mouseOn, true);
The mouseOn function:
function mouseOn(e) {
// Test for IE or Firefox
var e = (!e)?window.event:e;
var yPos;
[Code]...
I would like to pass in another parameter to the mouseOn function in addition to the event that is passed in automatically. Is there a way to do this?
View 5 Replies
View Related
Mar 3, 2010
I have little bizarre problem. Working in Java web development we have project that we use plenty of templates from Velocity. Where one template can refresh section of it self and display one or more templates. My problems is that in parent template I have to pop up window with message if in child template and item from group A been moved to group B or vice-versa. How to change on child template can be propagated up to parent?
View 3 Replies
View Related
Jul 2, 2009
I'm hoping someone might be able to clue me in on how the proper syntax for passing "flashvars" and "flash parameters" via Shadowbox to the JW FLV player should look. There is nothing in their docs that actually indicates exactly how one would properly format multiple variables and then send to the FLV player via flashvars. I've already posted to their forums but no response (typical). There is indication that this can be done on a per-link basis or via the Shadowbox.init() function; but again, though examples exist, none represent the type of situation I'm attempting to achieve. I've spent a ton of time combing their forums for some sort of clue and there are little nuggets but nothing definitive. My goal is to achieve the re-skining of the JWPlayer which is possible. I'm able to achieve this re-skining of the JWPlayer outside of the Shadowbox environment so I'm confident it can be done but I'm perplexed as to how to achieve.
[Code]...
View 1 Replies
View Related