473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to pass variable in a string

I actually want to pass a VARIABLE(that holds the name of the img tag) in
document.VARIABLE.src=imga
when i try using document.arg.src=imga, there is an error
but when i see the value of arg it contains the name of the img tag

How can i correct this or is there any other way to do it, If anyone can do this by DOM it would be great

[HTML]<html>
<head><TITLE>Universal Engineers</TITLE>
<script language="javascript">
function over(arg)
{
imga=new Image()
imga="images/bt2.gif"
document.n.src=imga
}
function out(arg1)
{
imgb=new Image()
imgb="images/rivet.jpg"
document.n.src=imgb
}
</script>
</head>
<body bgcolor=white>
<center>
<IMG SRC="images/ue.gif" border=0><br>
<IMG SRC="images/namaste1.bmp" border=0>
<table border=0>
<tr>
<td><IMG SRC="images/rivet.jpg" border=0 name=n alt="Profile" onMouseOver=over(this.name) onMouseOut=out(this.name)>
<td>
<td><IMG SRC="images/rivet.jpg" border=0 name=m alt="Flow" onMouseOver=over(this.name) onMouseOut=out()>
<td>
<td><IMG SRC="images/rivet.jpg" border=0 name=o alt="Level" onMouseOver=over(this.name) onMouseOut=out()>
<td>
<td><IMG SRC="images/rivet.jpg" border=0 name=p alt="Mass" onMouseOver=over(this.name) onMouseOut=out()>
</tr>
</table>
</center>
</BODY>
</HTML>[/HTML]
May 10 '07 #1
3 3153
pbmods
5,821 Expert 4TB
There are a couple of problems with your code.

Like the fact that you didn't use code tags when you posted your source.
May 11 '07 #2
Actually I did not get you,

How can I pass a varaible in a document.name.src=imga in place of name
May 11 '07 #3
gits
5,390 Expert Mod 4TB
Actually I did not get you,

How can I pass a varaible in a document.name.src=imga in place of name
pbmods wants to say that you should wrap your code-examples in CODE tags ... that makes it easier to read for everyone ...

an easy way to achive your goal would be the following example:

Expand|Select|Wrap|Line Numbers
  1. // prefer to use id in your image_tags and pass that to function over
  2. // over_images maps that ids to the desired image-sources
  3.  
  4. var over_images = {
  5.     m: 'desired_imagesrc.ext',
  6.     n: 'desired_imagesrc1.ext',
  7.     o: 'desired_imagesrc2.ext',
  8.     p: 'desired_imagesrc3.ext'
  9. };
  10.  
  11. function over(id) {
  12.     // gives you a ref to the img-node
  13.     var img = document.getElementById(id);
  14.  
  15.     img.setAttribute('src', over_images[id]); 
  16. };
  17.  
hope it helps ...
May 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rigga | last post by:
Hi I would like to pass a variable to an external program i.e. os.system('cd $variable') However this doesnt work, I cant figure it out, any ideas? Cheers
3
by: Nelson Broat | last post by:
In jsp land you can have the following: <% String name = "Nelson"; %> Hi, my name is <%= name %>. Such that, in your browser you see:
8
by: Vijay | last post by:
Hi all, Im using gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20) on 64bit linux server im trying to compile following code --------------------sam.cpp--------------------- #include...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
5
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into...
14
by: needin4mation | last post by:
I have this in my web service: public XmlDocument GetDataFromDB(string name) { .... do some stuff with name variable..on the database... return the XmlDocument to my datagrid; } Now, in my...
21
AccessIdiot
by: AccessIdiot | last post by:
Hi there, Extreme newbie here so hopefully this is an easy one. I have a switchboard with three buttons. Each button will open the same form BUT I need to pass a string depending on which...
14
by: Siegfried Heintze | last post by:
Why does VB.NET V2 force me to pass by value for my set function? When I try to change it to const byref it gives me a syntax error. It seems very inefficient to be passing strings around by value...
13
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.