473,320 Members | 1,909 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.

can a variable be used to store image

meenakshia
hi
i m not sure but wanted to use a variable to store an image and then show it inside the table
something like
Expand|Select|Wrap|Line Numbers
  1. var img1;
  2. img1="c:\myself.jpg";
  3.  
  4. and inside the table it shows like
  5. <table>
  6. <td>img1</td>
  7. </table>
  8.  
and this way it shows the image
is there a way to do such a thing
pls advice:)
smile always
anand
Jul 2 '08 #1
8 15734
acoder
16,027 Expert Mod 8TB
You could use document.createElement or the Image object constructor to create an image and then set its src, e.g.
Expand|Select|Wrap|Line Numbers
  1. var img = document.createElement("img");
  2. img.src="image.gif";
Jul 2 '08 #2
sir i m unable to use it properly pls check the code where i should make changes to make it work and get it displayed
sir,the area where i have inserted the code is in bold and unlined
in the result html it shows [object] as the display instead of the image
Expand|Select|Wrap|Line Numbers
  1. function getSearchResults()
  2.         {try
  3.             {
  4.              var para = document.getElementById("txtSearchPara").value;
  5.               var dbfile = getDBFile(); 
  6.               var cn = new ActiveXObject("ADODB.Connection");
  7.            var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source ="+ dbfile+ ";Persist Security Info=False";
  8.             cn.Open(strConn);
  9.             var rs = new ActiveXObject("ADODB.Recordset");
  10.             var SQL = "select *  from test where " + 
  11.             "clid like '%" + para + "%' or " + 
  12.             "tel2 like '%" + para + "%' order by clid desc";
  13.  
  14.             rs = cn.Execute(SQL);
  15.          var img = document.createElement("img");
  16.     img.src="logo.jpg";
  17.             var resultString = "<table>";
  18.                     resultString = resultString + "<tr> " +
  19.                     "<td>" + img + "</td>" + 
  20.                         "<td></td>" + 
  21.             "<td></td>" +
  22.                 "</tr>" ;
  23.  
  24.             var a1;
  25.             var a2=0;
  26.             var color;
  27.             var bcolor;
  28.             while (!rs.EOF ) 
  29.                 {
  30.                 color="#348781";  // green colour
  31.         bcolor="white";
  32.  
  33.  
  34.                     resultString = resultString + "<tr> " +
  35.                 "</tr>" +
  36.                 "</table>" +
  37.                 "<table>" +
  38.                     "<tr>" +
  39.                     "<td>" +"Stitching Number-"+ rs("clid")+"</td>"+
  40.                     "<td>" + "Trial Date-" +  rs("tdat")+ "</td>" +
  41.                     "<td>" + "Delivery Date-" +rs("ddat")+ "</td>"+
  42.                 "</tr>";
  43.                 rs.MoveNext();
  44.                 }
  45.                 resultString = resultString + "</table>";
  46.             rs.Close();
  47.             cn.Close();
  48.         document.getElementById("SearchResultPanel").innerHTML=resultString;
  49.            }
  50.            catch (e)
  51.            {
  52.                alert ("getSearchResults() : " + e);
  53.            }
  54.         }
  55.         </script>
  56. </head>
  57. <body onload= getSearchResults(); >
  58.  
  59. <div>
  60.     <table >
  61.         <tr>
  62.             <td>
  63.             <input type="text" name="txtSearchPara" tabindex="19" onblur = "getSearchResults();">
  64.            </td>
  65.         </tr>
  66.         <tr>
  67.         <td><SPAN id= "SearchResultPanel" style = "position: relative; width: 100%; "></SPAN>
  68.         </td>
  69.  
smile always:)
anand
Jul 3 '08 #3
realin
254 100+
sir i m unable to use it properly pls check the code where i should make changes to make it work and get it displayed
sir,the area where i have inserted the code is in bold and unlined
in the result html it shows [object] as the display instead of the image

smile always:)
anand
hiya,

this can be done like this:
[HTML]
<html>
<head>
<script type="text/javascript" >
var im="http://technofriends.files.wordpress.com/2008/03/google_logo_.jpg";
function create_img(){
var div = document.getElementById("pop");
var hold=document.createElement("img");
hold.src=im;
hold.border=2;
div.appendChild(hold);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<input type="button" onclick="create_img();" value="Create image" />
<div id="pop"></div>
</body>
</html>[/HTML]

hope this helps.. this works for me :)
cheers !!
Jul 3 '08 #4
hsriat
1,654 Expert 1GB
If you want to use it like this: "<td>" + img + "</td>", then use img to store the HTML for the image.
Expand|Select|Wrap|Line Numbers
  1. var img = '<img src="logo.png" alt="logo" />';
Or if you want the image to dynamically show up onclick of a button or something, then make it like this in your HTML:
[HTML]<img id="imageId" src="logo.png" alt="logo" style="display:none;" />[/HTML]

And with JavaScript, make it visible when required.
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('imageId').style.display = '';
Jul 3 '08 #5
hi hsriat
thanks a lot for the help
it worked and yes i m using it like +img+ inside the td tag
thanks once again:)
smile always
thanks forum
people like you are examples for how things should be done
really nice
god bless
anand
Jul 3 '08 #6
hsriat
1,654 Expert 1GB
hi hsriat
thanks a lot for the help
it worked and yes i m using it like +img+ inside the td tag
thanks once again:)
smile always
thanks forum
people like you are examples for how things should be done
really nice
god bless
anand
wow! :D
Thanks for appreciating our (forum's) work. :)

Regards,
Harpreet
Jul 3 '08 #7
hi harpreet
well i mean it
because it feels so nice to see people helping each other where as in real life we dont find a single person supporting each other:(
good to see good and positive people around:)
smile always:)
anand
Jul 3 '08 #8
acoder
16,027 Expert Mod 8TB
Must be a pretty sad place where you live.

No wonder you always sign off with "smile always" ;)
Jul 3 '08 #9

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

Similar topics

19
by: Skybuck Flying | last post by:
Hi, I think I might have just invented the variable bit cpu :) It works simply like this: Each "data bit" has a "meta data bit". The meta data bit describes if the bit is the ending bit...
7
by: Greg Collins [MVP] | last post by:
Hi, I couldn't find what I was looking for by searching the newsgroup, but perhaps these have already been discussed somewhere. This is a bit long with a lot of interrelated questions. What I've...
10
by: john_aspinall | last post by:
Hi, I got a bit of problem with Access and was wondering if someone could enlighten me. I'm building a database of products of sale, complete with images. Im importing the product data from...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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

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.