close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Dynamic Form

Thread began 3/11/2015 3:47 pm by Kumel | Last modified 3/12/2015 10:45 am by Kumel | 2096 views | 8 replies |

Kumel

Dynamic Form

Hi i was thinking how can we make a form where values are added in each form fields.

Its just like giving visitor a quotation or so depending upon options choosen.
Multiple form fields will be present.


Regards

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to have code the functionality to process the form input.

for example, if you have 2 form fields named element1 and element2. and each of these takes a numeric input, you can do simple math using the post:

<?php echo($_POST['element1'] + $_POST['element2']); ?>

Sign in to reply to this post

Kumel

How to display results?

Sign in to reply to this post

Jason ByrnesWebAssist

<?php echo($_POST['element1'] + $_POST['element2']); ?>

Sign in to reply to this post

Kumel

this is my current form:

<form id="form1" name="form1" method="post" action="">
<p>
<label for="element1"></label>
x:
<input type="number" name="element1" id="element1" />
<br />
y:

<label for="element2"></label>
<input type="number" name="element2" id="element2" />
</p>
<p><strong>x+y=z</strong></p>
<p>z: <?php echo($_POST['element1'] + $_POST['element2']); ?>
</p>
</form>



i get errors as such:


Notice: Undefined index: element1 in /Applications/XAMPP/xamppfiles/htdocs/esskaybee/test.php on line 21

Notice: Undefined index: element2 in /Applications/XAMPP/xamppfiles/htdocs/esskaybee/test.php on line 21
0


line 21 codes: <p>z: <?php echo($_POST['element1'] + $_POST['element2']); ?>

Sign in to reply to this post

Jason ByrnesWebAssist

you have to submit the form

Sign in to reply to this post

Kumel

cool. but error still seem to appear.

Sign in to reply to this post

Jason ByrnesWebAssist

you don't have a submit button in your form, so no way to submit it. you will need to add a submit button

you can add an if statement around the echo so it only shows when the form is submitted:

<?php if($_SERVER['REQUEST_METHOD'] == "POST") { ?>
<p>z: <?php echo($_POST['element1'] + $_POST['element2']); ?>
<?php } ?>

Sign in to reply to this post

Kumel

thanks a lot (y)

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...