473,748 Members | 8,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can a variable be used to store image

meenakshia
33 New Member
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 15893
acoder
16,027 Recognized Expert Moderator MVP
You could use document.create Element 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
meenakshia
33 New Member
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 Contributor
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.f iles.wordpress. com/2008/03/google_logo_.jp g";
function create_img(){
var div = document.getEle mentById("pop") ;
var hold=document.c reateElement("i mg");
hold.src=im;
hold.border=2;
div.appendChild (hold);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl ed 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 Recognized Expert Top Contributor
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
meenakshia
33 New Member
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 Recognized Expert Top Contributor
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
meenakshia
33 New Member
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 Recognized Expert Moderator MVP
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
2145
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 of a possibly large structure/field.
7
2167
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 got is a decodeImage.aspx page that gets called to decode base64 encoded images and return them as displayable images to a Web page. The ASPX page is passed two parameters, "file" and "img". The "file" parameter specifies and XML file on the Web...
10
1602
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 a CSV file into an access databse. The two main fields Im concerned with are called 'ProductID' and 'ImagePath'.
7
3731
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 rebuild. Does anyone have any suggestions on what I may have wrong. I am not sure if I built my table to store the picture id's correctly. Maybe a field type or something. <form name="UpdatePropertyPicture" method="POST"...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.