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

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 2472
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******@sbcglobal.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
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...
2
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
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...
0
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...
6
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...
17
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get the value of a form control? -----------------------------------------------------------------------...
7
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...
4
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...
3
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.