Passing A Function Within An Anchor Tag
Jan 12, 2007
I have a questionregarding passing a function within an anchor element href
during dom scripting using javascript. for eg:
the xslt file contains
<a href="javascript:{@test}('{@value}')">
how will i write this in javascript. Basically the xml file has
test = "help" and no value parameter in this particular xml file currently
the basic idea is to pass help('') in href of anchor tag
the help function is already defined.
i have currently written as:
var help = element.getAttribute('test');
var value = element.getAttribute('value');
elementA.href = 'javascript:help + '(' + value + ')'
value should be equal to ' ' where as in my case it is returning null and not sure on the syntax that i am using for href.
View 1 Replies
ADVERTISEMENT
Jun 9, 2010
my first attempt to post seems to either have been rejected or simply gone into the cyber void.
I currently have a link on a webpage as follows:
<a href="#" id="loadData"><img src="images/bookcase.png" alt="" width="114" height="167" border="0"></a>
which is picked up by
$("#loadData").click(function()
which then executes:
.load("subgenre.php" , function() etc
What I want to be able to do, however, is pass a parameter to the php script, along the lines of:
.load("subgenre.php?param=" + passedParam , function() etc
View 3 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
Aug 2, 2010
I have created a simple accordion that hides and shows span tags when the corresponding h3 header is clicked.
The Jquery:
$(".accordion span").addClass("answer");
$(".answer").hide();
$(".accordion h3").click(
[Code]....
However, I cannot work out how to test for the anchor and open the associated span tag
View 2 Replies
View Related
Mar 17, 2011
I want to create one menu with anchor tag for e.g=> <a href="http://www.example.com/example.php" rel="facebox">Example</a>
I want to write javascript function for that like
$menu = array();
$menu['page name without extension'] = 'Page Title To be showed on page';
function MenuGen()
{
}
In addition I want to add FACEBOX from [URL] or [URL]
View 1 Replies
View Related
Aug 18, 2010
But I was wondering is it possible to make it so that if you visited an anchor link: For example, let's say you visit:
Code:
[URL]
Then a code would run to let's just say... change the color scheme of the website. (And theoretically they same would happen with #v2/#v3, ect)
But the code would NOT run if the requested URL is just
Code:
[URL]
The reason I was wondering is I want the user to be able to "bookmark" a certain script per-say, so that when they revisit the site they don't have to reclick things to get back to where they were before.
View 7 Replies
View Related
Jun 24, 2009
I was wondering if someone could help me with this. I want to, when an anchor link is clicked, the id of the link is grabbed by jquery then passed to a function. The id is would be the same as the id of the div that is used for the function (highlight).
[Code]...
The code is a little messy but I am just testing right now. So if someone clicks on #aq1 link the id "aq1" is grabbed and used for the highlightFade function. It would highlight the div with id "aq1".
View 3 Replies
View Related
Jun 10, 2009
I'm confused as to why when I have:
$('a').click(function(){
alert(this);
return false;
[code]....
View 4 Replies
View Related
Oct 23, 2010
onClick="function(' whats the value of the anchor tag just clicked? Title basically says it. I need to get the object that was just clicked, to insert into a JavaScript function. I've tried "function('this')" and similar things, but it doesn't work. I'm sure this is REALLY easy to do, but I don't know it and I have no idea what to search for.
View 1 Replies
View Related
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
May 26, 2011
I need to get the page to reload with the anchor in the link when it is clicked in a dropdown menu. For example if I am on 'www.domain.com/about/#2' and I then click on 'www.domain.com/about/#3' the url changes but the page doesn't reload so I need the page to reload, but keep the new anchor (#3).I gave the links with anchors a class of 'reload' and tried this:
$('a.reload').click(function() {
window.location.reload();
});
View 4 Replies
View Related
Jan 9, 2010
I have a script that scans an HTML document for headers and special comment tags for the purpose of generating a left-floating/position-fixed DIV that contains the document's outline or "table of contents." Within the DIV are lists (UL element by default) whose items (LI elements) are jump-to links (A elements) to the points (headers, special points marked for inclusion in table of contents) in the document. The problem is this. I have typical HTML document with links that jump to points (usually headers) inside the document, as shown below:
Code:
<body>
<p>This is addressed <a href="#later-text">later</a> in this document
<h1><a id="later-text"></a>Header Text</h1>
<p>...
</body>
But my script, being a document outliner that finds headers in a document, inserts another anchor as a jump-to point just before the first occurrence of text in the header (inserted A element shown in red below). This somehow disables the document-coded jump anchor (shown in blue below). And it occurs in FF and IE, which suggests it is not a browser-specific issue. Why does it occur? Is there something in the HTML spec that states that two anchors to which a jump occurs are not allowed to be adjacent elements in the document?
Code:
<body>
<p>This is addressed <a href="#later-text">later</a> in this document
<h1><a id="later-text"></a><a id="jump-1"></a>Header Text</h1>
[code]....
To reproduce what I am seeing, search for the text "Why Is A Survey Done". The first occurrence is a within-document jump-to link, which should jump to a header below it. If the script execution to generate a document outline is disabled, the jump works. But if the script is executed and the document outline generated, the jump-to link does not work.
View 2 Replies
View Related
Jul 25, 2011
I started with the simplest step - the hide() function:
$(document).ready(function(){
$("a#p").click(function(event){
$("#HiddenDiv").hide();
})
});
It worked fine as long as the href attribute of the anchor tag was '#'. Then I tried using href other than '#' and ran into a problem. I just changed the href to:
<a id="p" href="test.php">Click me</a><br />
<div id="HiddenDiv">Testing mate</div>
test.php is the page in which both these sections (html and jquery) are present, so like a postback to the same page.
This method didn't work and on clicking the anchor tag, the div stayed visible.
I then tried theevent.preventDefault(); method and that worked.
So I experimented more. I tried using the hide function on a dynamic link, something like test.php?a=1.
I ran into a problem again. The div remained visible on clicking that link.
View 17 Replies
View Related
Oct 23, 2010
I need to get the object that was just clicked, to insert into a JavaScript function. I've tried "function('this')" and similar things, but it doesn't work.
View 3 Replies
View Related
Jan 6, 2012
I have a lot of similar instances of the following code on my page:
$('#btnEditParty').click(function () {
$.ajax({
type: "POST",
url: "WardAdmin.aspx/GetParty",
[Code]....
I'd like to create a generic function to save repeating a lot of code and then just pass in the relevant values.
I'm fine with that, the only thing I'm not sure about is if/how I can pass in a function name to be called on success/fail.
This post is where I was doing something similar to save repeated code: [URL]
In a similar way is there a way of passing in a function name to be called on success?
View 1 Replies
View Related
Sep 4, 2011
Having a little bit of trouble with a site I'm currently working on I'm using some AJAX for the instant g-mail/facebook style navigation, you know the kind, with no refreshes, etc. Problem is, to allow for back/forward and bookmarks, I currently use a URL that looks like:[URL].. This is fine, not a problem... The issue comes into play when I want to open up the news.html page, from my home.html page, and have it open to news item #6 (for example).
I can't add a #, because one is already being used to reference the anchor for the content div. Has anyone run into a similar problem before? If so, how did you resolve it? Can some jQuery be used to find the location of the news item div in question, on load, and scroll to it like that?
View 8 Replies
View Related
Feb 18, 2010
I have issue with passin value between functions:
$(document).ready(function(){
id = 'test';
$('#Meno').keyup(function(){
id = '#Mobil';
[Code].....
I am getting from console.log right value "#Mobil" but $(id) has value "Test". I need there also value "#Mobil".
View 2 Replies
View Related
Feb 3, 2010
In one variable i have some data ex: var data = document.getElementById("imageId").value; I want to pass this data to another function inside another function ex: var button1 = '<img src="images/Remove-button.gif" width="70" height="15" onclick="removeVerifyImageRow(this),saveLibData('+data+')"/>';
while running the application i am getting an error incase if the data is string ex:if data is 'image1' i am getting an error, but with number there is no problem ex: if data is '1122'.
View 7 Replies
View Related
Feb 10, 2010
Here is the code:
for (var i = 0; i < BS_crm['activityTypes'].length; i++) {
var clickFunc = function(){ activityList.showForm( -1, {blockType:[""+BS_crm['activityTypes'][i]['id'], "0"]} ); };
var type = {
[Code]....
Now, basically what I am doing here is running through one array to create an array of objects, that will be used to create links that will use whatever onClick function I pass it. The problem is that on the second line I need the BS_crm['activityTypes'][i]['id'] to be a value, not a reference. If that line was simply changed to:
var clickFunc = function(){ activityList.showForm( -1, {blockType:["3", "0"]} ); };
View 4 Replies
View Related
Feb 3, 2010
In one variable i have some data ex: var data = document.getElementById("imageId").value; I want to pass this data to another function inside another function ex:
var button1 = '<img src="images/Remove-button.gif" width="70" height="15" onclick="removeVerifyImageRow(this),saveLibData('+data+')"/>';
while running the application i am getting an error incase if the data is string ex:if data is 'image1' i am getting an error, but with number there is no problem ex: if data is '1122'.
View 5 Replies
View Related
Feb 8, 2011
What syntax do I use to pass the div_name argument value to the rotate function in the setInterval function? I can't seem to get it to work.
Code JavaScript:
function theRotator(div_name) {
//Set the opacity of all images to 0
[code]....
View 2 Replies
View Related
Oct 5, 2010
I'm trying to pass titleArray and pointsArray to the task(); I'm getting an error mgs this.assignments() is not a function. I've highlighted this.assignments()
[Code]...
View 6 Replies
View Related
Dec 4, 2006
I found a JS function I'd like to use, which animates a layer so that
it moves across the screen.
The problem is the function, as found, simply names the DIV directly. I
want to be able to use the function in the HTML to pass the ID of the
DIV which gets moved. Sounds fairly straight-forward, right? Well it
doesn't work and I have spent HOURS on this. Yes, I am red-faced. Code:
View 6 Replies
View Related
Jan 12, 2010
There is <span id="id1234" style="visibility: hidden">NOT </span>hidden content here.
<script type="text/javascript">
function showIt(uniqueID) {
document.getElementById(uniqueID).style.visibility = "visible";
[code]...
View 5 Replies
View Related
Apr 21, 2006
I have a system that I want to try, which requires me, from an aspx
page, to call a generic function to work perform one task, then i want
to call another function with the results of that task.
something like this:
in my aspx page:
<input type=button onClick="doFirstFunction('secondFunctionName');">
then in my .js file:
var functionToCall = ''
function doFirstFunction(functionName) {
functionToCall = functionName
// do the initial, common task
sResult = xmlHttp.responseText
//now call the second function, passing sResult to it
}
Right now I'm using 'switch' and manually adding possible values for
'functionName' then directing manually, but I'd like to make
"doFirstFunction" self-maintaining, i.e. without having to update it if
I add more 'second' functions later.
I thought I could use
eval('functionToCall('+sResult+')');
View 17 Replies
View Related
May 8, 2006
I have two functions that are stacked in so much that the second function calls the first.
function1() {
[...]
}
return value;
};
function2() {
[...]
function1()
}
var = function1 returned value
function 1 is function correctly as i have got it to display the data to the screen durrning testing it. however, i have not yet come across a way in which i can get the returned vale into function 2 ...
View 4 Replies
View Related