473,581 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can PHP control a form value directly

Ok. Can PHP control a form value directly? Eg. like the javascript
"document.Form1 .text01.value = "Y"". Eg. allow me to put a value into
a form text field on page load. Either I missed this in my PHP book
or the function does not exist.

The only way I have seen is to put code in the value part of the input
item, see below.

Thanks

<input type="text" value = "<? echo sprintf("%01.2f ",
$TotalCost);?>"/>
Sep 5 '05 #1
6 2487
David said the following on 05/09/2005 23:06:
Ok. Can PHP control a form value directly? Eg. like the javascript
"document.Form1 .text01.value = "Y"". Eg. allow me to put a value into
a form text field on page load. Either I missed this in my PHP book
or the function does not exist.
PHP is server-side, so it has no control of the form, other than the
HTML/Javascript/etc. that is sent to the browser.

The only way I have seen is to put code in the value part of the input
item, see below.
<input type="text" value = "<? echo sprintf("%01.2f ",
$TotalCost);?>"/>


So this (and variants) are the only way of doing this.

--
Oli
Sep 5 '05 #2
David (ma******@sbcgl obal.net) wrote:
: Ok. Can PHP control a form value directly? Eg. like the javascript
: "document.Form1 .text01.value = "Y"". Eg. allow me to put a value into
: a form text field on page load. Either I missed this in my PHP book
: or the function does not exist.

: The only way I have seen is to put code in the value part of the input
: item, see below.

: Thanks

: <input type="text" value = "<? echo sprintf("%01.2f ",
: $TotalCost);?>"/>

Normally php is simply generating text to send to the browser, so yes,
normally the above is exactly what you have to do (give or take the choice
of php commands to use).

If you use a template system to generate your output then there may be a
technique provided by the template system to set a value. In that case
you create and populate your template and then send the template, as a
long text string, to the browser. Whether the template control language
looks similarly to Javascript will depend on the template system.

One special case of a template system is to use something like an xml
builder library. Your php program can build an xml data structure in
memory. That DOM can be manipulated all you like. When it is ready you
send a stringified version of the DOM to the brower.

In no case, however, you are ever manipulating the value on the browser
like javascript would. All you can ever do is prepare a finished version
of the html text (including what ever values you wish) and then you send
that finished text to the browser.

Well actually, if you run a Java applet on the browser then the server may
have the ability to communicate directly with the values being displayed,
but that is a whole other kettle of coffee, and I have no idea what (if
any) php libraries would help you do that. (Not to mention that you would
probably need to write your own custom Java applet as well). I mention
this just for completeness, it is not something most web programmers will
ever do.

--

This programmer available for rent.
Sep 5 '05 #3
No.

That being said you could always remote with Flash or Processing or a
POJA.

Sep 6 '05 #4
Thanks for the info. I guess I have been having too much fun with
ASP.net, which allows direct asp forms access.

Need to shift back to the php mindset!
On Mon, 05 Sep 2005 22:45:53 GMT, Oli Filth <ca***@olifilth .co.uk>
wrote:
David said the following on 05/09/2005 23:06:
Ok. Can PHP control a form value directly? Eg. like the javascript
"document.Form1 .text01.value = "Y"". Eg. allow me to put a value into
a form text field on page load. Either I missed this in my PHP book
or the function does not exist.


Sep 8 '05 #5
I noticed that Message-ID: <j6************ *************** *****@4ax.com>
from David contained the following:
Thanks for the info. I guess I have been having too much fun with
ASP.net, which allows direct asp forms access.


Yebbut, it uses Javascript to do it!

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Sep 8 '05 #6
Geoff Berrow <bl******@ckdog .co.uk> wrote:
I noticed that Message-ID: <j6************ *************** *****@4ax.com>
from David contained the following:
Thanks for the info. I guess I have been having too much fun with
ASP.net, which allows direct asp forms access.


Yebbut, it uses Javascript to do it!


Exactly. I've sometimes wondered how many ASP.NET programmers realize that
their simple forms code is generating hordes of Javascript, and that many
seemingly simple user interface actions require rather expensive round
trips.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Sep 10 '05 #7

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

Similar topics

6
3395
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get sized strangely using the .RTFHeight property of the control. Specifically, lines of text get cut off the bottom of the control when I use the code...
2
3613
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
9
2878
by: TCORDON | last post by:
I have a user control that contains 2 image buttons, when you click one of them, both must change the image source, the thing is that the first time you click any one of them the page appears to do a postbak, but the image source or the image displayed does not change until I click one of the images a second time, why dows it take 2 clicks for...
0
5557
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control is used to view the state of the running jobs and schedule new jobs. The control also runs in the context of Internet Explorer (we do this so the...
6
4063
by: evandelagrammaticas | last post by:
Hi all. I have spent the better part of a day scouring the newsgroups and I am sure that I must have come across the solution a number of times - but I am still a real newbie at asp.net so please forgive me beforehand if I ask anything really simple or ridiculous. I am going to simplify my query... the structure of my example is --->...
17
479
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get the value of a form control? ----------------------------------------------------------------------- In HTML documents, named forms may be referred to as named properties of the « document.forms » collection, and named form controls may be...
7
12291
by: ApexData | last post by:
I am using the following code in my TabControl to manage subform loads. The code assigns the subForms SourceObject. - Do I also need code to DeAssign the SourceObject when leaving the Tab, I'm thinking the Table will stay open otherwise ??? - Do I also need to use code to Assign the Child&Master Links, or can I just type the names into...
4
2474
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried unsuccessfully in creating the whole pane as a user control and have succeeded in adding the pane and then dynamically adding the content which is a user...
3
5251
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first add the pane the remove event does not get handled, though thereafter it is handled without problems....
0
7886
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
7809
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8159
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7920
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...
0
8183
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...
0
6569
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...
0
5366
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
3809
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...
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.