473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you write this Javascript in PHP?

Don
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javas cript">
//
function passfile1path()
{
var path = document.proces sPictures.userf ile1.value;
document.proces sPictures.file1 path.value = path;
}
</script>

<form...>
<input type=file name="userfile1 " onfocus="passfi le1path();" size=90 maxlength=20000 00
accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>
-------------------------
Just when I think I'm getting to know a little bit about PHP, I run into another stumbling block.
Thanks for your help.
Don
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 17 '05 #1
3 2674
Don wrote:
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javas cript">
//
function passfile1path()
{
var path = document.proces sPictures.userf ile1.value;
document.proces sPictures.file1 path.value = path;
}
</script>

<form...>
<input type=file name="userfile1 " onfocus="passfi le1path();" size=90
maxlength=20000 00 accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>
-------------------------


You can't do that in PHP. Javascript is a client based programming language
and your code example is responding to events triggered in the client. PHP
runs on the server.

I'm a little confused why you need to assign the value of the "userfile1"
file box to a hidden variable anyway, as the $_FILE array in PHP will be
populated with everything you need.

Refer to the manual at http://www.php.net/features.file-upload for more
information about how to handle file uploads.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2
Don wrote:
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javas cript">
//
function passfile1path()
{
var path = document.proces sPictures.userf ile1.value;
document.proces sPictures.file1 path.value = path;
}
</script>

<form...>
<input type=file name="userfile1 " onfocus="passfi le1path();" size=90 maxlength=20000 00
accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>

You don't. That javascript performs a client side operation. PHP only
works on the server side.
Jul 17 '05 #3
2metre <2m****@xxxhers ham.net> wrote in message news:<cl******* ***@hercules.bt internet.com>.. .
Don wrote:
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javas cript">
//
function passfile1path()
{
var path = document.proces sPictures.userf ile1.value;
document.proces sPictures.file1 path.value = path;
}
</script>

<form...>
<input type=file name="userfile1 " onfocus="passfi le1path();" size=90 maxlength=20000 00
accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>

You don't. That javascript performs a client side operation. PHP only
works on the server side.


could echo it out, if just wanted it in the code
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2372
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of copying/pasting everytime I change it, I figure this will be better, as I only change it once. The problem is, document.write doesn't handle multiple...
2
3533
by: Geoff Wilkins | last post by:
I am using <SCRIPT src=...> to import a Javascript routine from a remote source. I am then using some of the variables given values in the routine, in my own Javascript.. Unfortunately the routine also outputs to the page using document.write. I don't want this output. Any ideas how I can get rid of it? -- Best wishes,
8
17883
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row. How do I do it? I think one way is to write the entire table out in document.write("<table>...) but I'd like to know if it is possible to access...
13
9599
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
4
2942
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400, like DOS, uses memory-mapped display, two bytes per character (one char byte and one attribute byte). We can get the screen offset allright, and...
12
2829
by: Sean | last post by:
Hi, I have the following script: ----------------------------------------------------------------------------------- <script type="text/javaScript"> <!-- document.write('<div id=hello1>Hello1</div>'); document.write('<div id=hello2 style="display:none;"><script src="test.js"><\/script></div>');
2
5756
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
9
2196
by: sonnystarks | last post by:
I am taking a course in writing javascript and it (and all the books I have been reading) tell me that if I will use the document.write syntax, I will be able to "place text on the page." None of these sources tell me why I would do that instead of using ordinary HTML which is less typing. (I think I understand that it is somehow...
3
3297
by: =?Utf-8?B?SmFzb24gSGFydHNvZQ==?= | last post by:
I get the error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write...when i postback to the page. The problem is, i need to write some dynamic javascript on postback and make sure it's...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8118
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...
1
7665
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...
1
5501
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...
0
5217
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...
0
3651
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
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...

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.