Passing Var To Function Within A Href?

Apr 1, 2010

I'm trying to trigger a function when the user clicks on an image. The function will test for whether a variable passed to it is empty or not and branch accordingly. The image has an <a href> behind it that triggers the function OK, but I cant seem to pass a variable to the function. The variable contains a value from a database field, and I think it is probably a syntax thing because if I set the variable to contain a string instead (i.e. b = 'this works') within the <a href> it works OK. So the problem may be with setting the variable to contain the database field value within the <a href> here's the code:

[ICODE]
"<center><a href=""javascript:void(null)"" onClick=""goConfirm(b);"" b = ""<%=RS(8)%>;"" title=""Get map (open new window or tab)"" ><IMG src=""images/bt_compass.gif"" border=""0"" /></center></a>"

[Code]....

View 5 Replies


ADVERTISEMENT

JQuery :: Href In Output Code Causing $getJson() Function To Try To Load Up A File With Href In Url

Jul 12, 2010

I'm using the following code (simplified version) to call a Json file, parse it and on each iteration, create a div with an ID of "tab". I'm using this with jQuery UI .tab() to create a listing with entries which have three tabs. Anyhow, the principle seems to work except that when I examine what's happening behind the scenes using Firefox console, I see that each href in the html code produced is causing the Json function to re-fire using the href as it's url target.

<!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" xml:lang="en" lang="en">
<head>

[Code].....

View 6 Replies View Related

Passing Variable To A Href?

Jan 20, 2011

im trying for last 4 days. please help me out

Code:
<input name="name" type="text" value="Raj" />
<a href="01.php?name=(document.getElementById('name').value" class="nyroModal" rev="modal">click here</a>

View 2 Replies View Related

Passing A JavaScript Variable In Href

Oct 26, 2005

For ease of future modifications on my page, I want to have a list of URLs stored in an Array, and I want to then use these URLs in an href tag. Something like this:

<SCRIPT>
menuURL[0]="page2.htm";
menuURL[1]="javascript://";
...
</SCRIPT>
<BODY>
<A HREF = menuURL[0] ........

How is something like this possible, as well as being fairly crossplatform, and intuitive? I've changed the syntax, and tried various other things to no avail.

View 3 Replies View Related

Change Href Using A Function.

Jul 23, 2005

I have a button that change a number of images src's when I click a
button. The src's are stored in an array and I just use
document[imgName1].src=pics[0] to change the src of the image.
However I want the button to change the link as well to the image that
is displayed but i cannot get it to work. How do I do this. Could
someone tell me or point me in the direction of some code that will do
this.

I would like to do it in a similar way to the pictures. i.e. have all
the links stored in an array and change them when the button is
pressed.

View 2 Replies View Related

Multiple Function Href

May 7, 2007

I would like to do multiple functions on one onclick, then go to a new page.
Here is my attempt using one function to do two things. Suggestions please

<SCRIPT language="JavaScript">
function submitform()
{
document.form.submit();
default_b.php?action=add_item&id=<?php echo $row["id"]; ?>&qty=1">
}
</SCRIPT>
</head>

<body>
<form name="form" action="">
<input type='checkbox' name='chk'>

</form>
<A href="#" onClick=" submitform();return false;">Add Item</A>

View 1 Replies View Related

Why Href Does Not Work With This Function

Jun 20, 2010

I've a problem with this ajax function, the url doesn't actualize. I want to see the hash in url, but with the function it's not possible. Why?The code I use in php is:

Code:

<br><a href="#nosotros" onClick="FAjax('nosotros.php' ,'capaContenedora','','get'); return false"><b>nosotros</b></a>

And the function is:

Code:

function FAjax (url,capa,valores,metodo)
{
var ajax=creaAjax();
var capaContenedora = document.getElementById(capa);

[code]...

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

Set A Href Or Onclick Function For An "a" Element That Passes Information To The Function?

Jan 1, 2011

How can I set a href or onclick function for an "a" element that passes information to the function?I have a function showpage() that is called whenever one of a number of buttons are clicked. I need to pass information from the button clicked to that function.

View 4 Replies View Related

JQuery :: Passing The Success Function Name Into A Generic Function?

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

Change Href And Title From Function?

Dec 17, 2010

I am having a problem changing HREF and Text of a link from javascript. My code is as colos <a href="javascript:Action(9,'remove');" id="thelink">Remove</a>

And the javascript code is:

[Code]..

View 2 Replies View Related

Calling Function Using Href Not Working In IE8?

Mar 7, 2011

I have a page that loads various "applications" into an iframe inside the main page. One of the applications loaded calls a javascript function that is loaded with the "application" page. It works great in Safari, Chrome & Firefox but error's out in IE8 - "Object doesn't support this action". Have other calls that work but this one is the only one that uses href

[CODE]
<div id = 'trainingsubmitbutton' style='display:none;'><a href='javascript: submitdata(0)'>Submit This Record</a></div>
[CODE]

View 6 Replies View Related

JQuery :: Carry The HREF Of A Link Through Function?

Nov 18, 2010

I should not be coding, to be honest, I know nothing about it ...

I have a link:

<a href="linkedfile.html">LINK</a>

I want the HREF value to be carried through my jQuery function. The function goes as follows:

User clicks link Linked icons fade out and reappear smaller at the top of the page Link HREF is followed

The new page will have the logos in the same place as they fade out too and content will appear in a frame below. However, I am clueless when it comes to Ajax and jQuery and would really like to learn, hence why I am using it. How do I carry the HREF through? Or are there better ways to do it?

View 1 Replies View Related

Include "location.href = URL In A Function?

Aug 28, 2010

I am so lost with JavaScript functions. How do you include "location.href = URL in a JavaScript function?

View 2 Replies View Related

Having A Link Which Runs A Js Function (acceptable To Have No Href?)

Jul 17, 2006

question: if you want a link which simply runs a js function is it acceptable to have no href? the problem with this is the cursor doesnt change when you hover over, but if you put # as the href it jumps to the top of the screen which is sometimes unacceptable. what it the best solution to this? granted you could do event handling behind the scenes and just intercept the clicks and prevent the href from going anywhere, but sometimes you just want to stick an onclick on the anchor tag!

View 5 Replies View Related

JQuery :: Passing Value From Function To Other Function Selector

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

Passing Data To Another Function Inside A Function

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

Passing Variable To A Function Inside A Function?

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

Passing Data To Another Function Inside A Function?

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

JQuery :: Click Function Of Anchor Tag Not Working With Href Other Than #?

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

Can I Pass The Name Of A Javascript Function To A Page Opened With An Href

May 26, 2007

I'm not sure whether or not this is possible, but I want to have control over the Javascript function that is called when a target web page is opened (ie as the onload function in its <body> tag). In other words, the calling page will have several <a href ...> tags referencing the same page, each specifying a different onload function. Is it possible to effectively pass a parameter in this way? I have not been able to find any solution to this.

View 2 Replies View Related

JQuery :: Moderately Complex Function - Apply The Href Attribute

Feb 1, 2011

This isn't working. I'm using the code below to try to apply the href attribute of the first td in a row with class DataFormListTDDataGridItem and apply it to all td elements in that row (effectively want to make entire row clickable and direct it to the href specified by the href attribute in the first td of the row) -

Table looks like this -

View 9 Replies View Related

Handle A Callback Event Before It Performs The Default Href Function?

Mar 1, 2010

how to handle a callback of an event, before it performs the default href function.

<code>
<a href = '<?php $url ?>' onclick = myFunction(); return true;>Click Here</a>
</code>

I want the onclick event to finish completing and then perform the default href function, which is denoted by the "return true". The javascript "myFunction()" opens a window in a pop-up and it has a submit button in it. I would like to wait till this page loads in the pop-up window and only after the user clicks on the close button, the default href function needs to be carried out. I cannot figure out on how to get the callback from this event.

View 1 Replies View Related

Overriding '<a Href' With '<a OnClick' For JavaScript Function OpenWindow(URL) For Image And Link...

Jul 23, 2005

Can anyone assist me with what I am trying to do with the following
code (six different scenarios to try to make the functionality work
correctly)?

I want to always (and ONLY) display in the status bar 'Symantec
Corporation' whenever anyone mouses over (onMouseOver) my image or
link OR when one clicks while holding the left mouse down (onClick) on
the same image or link. Upon releasing the mouse (onMouseOut), the
status bar should be 'blank'. I need the link to open in a new window
via my function openWindow(URL) code.

What is happening in most of the six scenarios, is that when one
clicks the link, either the function doesn't engage, but rather the <a
href= takes effect instead OR that status bar shows
'javascript:openWindow('http://www.symantec.com/');' when one clicks
while holding the left mouse down (onClick) on the image or link.

Additionally, for only the link, I need the CSS/style to show 'red'
when one mouses over (onMouseOver) it and then change to 'blue' upon
releasing the mouse (onMouseOut).

How about integrating 'style="cursor:hand"' into the code or perhaps
setting some of the data via a <div> or <span> snippet? Code:

View 2 Replies View Related

Script Unable To Create Href In Div And To Apply Second Mouseover Function / Solve It?

Sep 1, 2010

The code below lays out 3 divs, the 1st. div contains a slideshow, the 2nd. div is a container for the 3rd div which contains buttons to override the slideshow and replace it with a new image in the slidshow div.

All the above scenario works perfectly.

Where I run into trouble is as follows:
1. When a button is hover, the image needs to change but I already have a onmouseover() function for each button
2. When the image changes, it need to have a href to example: file8.php to open in _self - I have 2 commented lines in my changeIt function to show the last things I tried. code...

View 1 Replies View Related

Passing Function Argument Value To Another Function?

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







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