Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Auto fill field...

Engaged ,
May 14, 2007 May 14, 2007

Copy link to clipboard

Copied

I have a form which collects some currency value data.

what I am trying to achieve is to obtain a calculated value, based on the above, which would then appear in another text field automatically before submit. This value would then be saved to the db on submit.

for instance:

<?php
$unitvalue=$POST_VARS['textfieldunitvalue'];
$quantity=$POST_VARS['textfieldquantity'];
$totalvalue=($unitvalue*$quantity);
?>
<td><input name="textfieldtotalvalue" type="text" id="textfieldtotalvalue" value=$totalvalue></td>

I assume though that both the GET and POST methods only activate on "sumbit"

How then do I achieve an autofill functionality?

Is there a simpler solution?
TOPICS
Server side applications

Views

386
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 14, 2007 May 14, 2007
On 14 May 2007 in macromedia.dreamweaver.appdev, geschenk wrote:

> youïre approach is correct, but youïll need to enclose the text
> fieldïs value in <?php ... ?> and in here "echo" the variable,
> means:
>
> <td><input name="textfieldtotalvalue" type="text" id="textfieldtotalvalue" value="<?php echo $totalvalue; ?>"></td>
>
> The way it ïs now, the visitor would be able to change or erase the
> fieldïs contents, so if you donït want this to happen, you should
> better make this a hidden fie...

Votes

Translate
Guide ,
May 14, 2007 May 14, 2007

Copy link to clipboard

Copied

Hi,

you´re approach is correct, but you´ll need to enclose the text field´s value in <?php ... ?> and in here "echo" the variable, means:

<td><input name="textfieldtotalvalue" type="text" id="textfieldtotalvalue" value="<?php echo $totalvalue; ?>"></td>

The way it´s now, the visitor would be able to change or erase the field´s contents, so if you don´t want this to happen, you should better make this a hidden field, means...

<input type="hidden" name="textfieldtotalvalue" id="textfieldtotalvalue" value="<?php echo $totalvalue; ?>">


...and additionally "echo" the result as plain text

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2007 May 14, 2007

Copy link to clipboard

Copied

On 14 May 2007 in macromedia.dreamweaver.appdev, geschenk wrote:

> youïre approach is correct, but youïll need to enclose the text
> fieldïs value in <?php ... ?> and in here "echo" the variable,
> means:
>
> <td><input name="textfieldtotalvalue" type="text" id="textfieldtotalvalue" value="<?php echo $totalvalue; ?>"></td>
>
> The way it ïs now, the visitor would be able to change or erase the
> fieldïs contents, so if you donït want this to happen, you should
> better make this a hidden field, means...
>
> <input type="hidden" name="textfieldtotalvalue" id="textfieldtotalvalue" value="<?php echo $totalvalue; ?>">
>
>
> ...and additionally "echo" the result as plain text

Actually, since this is a derived value, it shouldn't be stored in the
database at all; it should be calculated when the value comes out of
the database. At a minimum, the calculation should be done
serverside, just before inserting it. Any time you create the value
by calculating clientside, some enterprising site visitor could create
their own form to submit this information.

You can display the information in unchangable form like this; note
the 'disabled' attribute:

<input
name="textfieldtotalvalue"
type="text"
id="textfieldtotalvalue"
value="<?php echo $totalvalue; ?>"
disabled="disabled">

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 14, 2007 May 14, 2007

Copy link to clipboard

Copied

LATEST
I should have thought of this before!

Many thanks for your comments.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines