473,394 Members | 1,717 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,394 software developers and data experts.

How to pass file name to a Function

ak1dnar
1,584 Expert 1GB
Hi, I am trying to send a file name to a JS function. but the problem is from I can pass some integer values for the function and i can display the alert box.
but not for the filenames.

this one is working:
[HTML]<a href="javascript:file_down(1001)"><img src="images_store/b_down.jpg" width="21" height="22" border="0" /></a>[/HTML]
this one is Not working:
[HTML]<a href="javascript:file_down(file_name.pdf)"><img src="images_store/b_down.jpg" width="21" height="22" border="0" /></a>[/HTML]

Expand|Select|Wrap|Line Numbers
  1. function file_down(fid)
  2. {
  3. var myvar = fid;
  4. alert(myvar);
  5. }
Mar 15 '07 #1
6 4264
You're missing single qouotes around the string being passed to the function.

[HTML]<a href="javascript:file_down('file_name.pdf')"><img src="images_store/b_down.jpg" width="21" height="22" border="0" /></a>[/HTML]
Mar 15 '07 #2
ak1dnar
1,584 Expert 1GB
Actually In my Application I am printing these JS from PHP. thats why i couldn't put the quotes. Anyway thanks :) I'll try to fix it up.

[PHP]echo 'href="javascript:file_down('.$row['p_man'].')"';[/PHP]
Mar 15 '07 #3
acoder
16,027 Expert Mod 8TB
You can put quotes in. Just escape them.
Mar 15 '07 #4
ak1dnar
1,584 Expert 1GB
You can put quotes in. Just escape them.
Sorry , I didn't get you. how to escape it.

[PHP]echo '<a href="javascript:file_down('.$row['p_man'].')">Image Goes Here</a>';
[/PHP]
Mar 15 '07 #5
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. \'
Use the backslash key for escaping quotes
Mar 15 '07 #6
ak1dnar
1,584 Expert 1GB
Oooops, Thanks. :)
Mar 15 '07 #7

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

Similar topics

23
by: John | last post by:
Last year, I remember finding a web page describing how to pass the name of a file to another web page, and have that web page load that image file. Now, I can't find my record of that (it was...
2
by: Aaron | last post by:
I have a data sructure setup and I populate it in a loop like so: y=0 while X: DS.name = "ASDF" DS.ID = 1234 list = DS; y = y + 1
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
5
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the...
28
by: Bill | last post by:
Hello All, I am trying to pass a struct to a function. How would that best be accomplished? Thanks, Bill
5
by: gdarian216 | last post by:
can I pass grades.projects in my function call that is void get_scores(ifstream& infile, int num_scores, grades.projects) and the function would look like void get_scores(ifstream& infile, int...
1
by: Rocky86 | last post by:
hi ppl bascially I am require to pass my php coding to actionscript and the actionscript will seperate the code of my php how do I do it? Must I create a function for php to be pass into actionscript...
6
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.