Antworten auf deine Fragen:
Neues Thema erstellen

Hilfe bei mathematischer Berechnung

Aelfry

Web Developer

AW: Hilfe bei mathematischer Berechnung

Hilfe, ich möchte 5 Eingabefelder mit einer mathematischen Formel zu einem Ergebnis das Ausgegeben werden soll zusammenfassen.

Wie geht das?
Du musst erst die Inhalte der Felder auslesen (GET/POST) und ggf. einer Variablen zuweisen.
Dann kannst du damit rechnen was du willst.
 

Duddle

Posting-Frequenz: 14µHz

AW: Hilfe bei mathematischer Berechnung

Soll das server- oder clientseitig ablaufen? Das heißt, muss zur Berechnung irgendwas internes / aus der Datenbank bedacht werden, oder ist es ein simples a*b*c/2?

Für ersteres musst du, wie von Aelfry gesagt, . Für letzteres reicht eine JavaScript-Funktion, die die Werte nimmt, zusammenschmeisst, und das Ergebnis präsentiert (wird bspw. in diesem .pdf erklärt.

Edit: aus deiner Antwort oben schließe ich, dass du keine/kaum PHP-Erfahrung hast. Dann solltest du anfangen, sonst musst du dir jeden kleinen Schritt erklären lassen.


Duddle
 

d4y

Pixel schupser

AW: Hilfe bei mathematischer Berechnung

@Duddle

Danke ist eine simple Berechnung ohne extra Daten a*b*c*d+e werde mich mal durch das Pdf arbeiten. Nochmals vielen Dank fuer die Hilfe

Habe folgendes gebastelt:

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>


</head>
<script type="text/javascript">
<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://www.javascriptsource.com
Based on a script Created by: Matthew Ogden :: http://www.home.earthlink.net/~ogden1972/ */

function d(){
  var a = document.form1.hight.value;
  var b = document.form1.length.value;
  var c = document.form1.depth.value;
  var costb = document.form1.chem.value;
  var cost = document.form1.cost.value;
  mpg=(a*b*c*cost)-(-costb);
    mpg= Math.round(mpg*10)/10;
 
  document.form1.results.value="You spent "+mpg+" Euros to refill your pool.";
}
// End -->
</script>// JavaScript Document



<body>

<div align="center">
<h3>Cost calculation for refilling a poolr</h3>

<form name="form1">
<strong>Pool length</strong>**
<input type="text" size="4" name="hight"><strong> m</strong><br><br>**
<strong>Pool with</strong>**
<input type="text" size="4" name="length"><strong> m</strong><br><br>**
<strong>Pool depth</strong>
<input type="text" size="4" name="cost"><strong> m</strong><br><br>**
<strong>Water price per m3</strong>
<input type="text" size="4" name="depth"><strong> Euro</strong><br><br>
<strong>Price for Chemicals</strong>
<input type="text" size="4" name="chem"><strong> Euro</strong><br><br>
<input type="button" value="Calculate" onclick="d()">*<input type="Reset" value="Clear"><br><br>
<strong>Results</strong><br>
<textarea name="results" rows="5" cols="55" wrap style="border-width:0;overflow:hidden"onfocus="this.blur()">
</textarea>
</form>
</div>
</body>
</html>

Auf einer einfachen html Seite funktioniert es, nun besteht meine Seite aber aus einem css template und wenn ich den Code einfüge funktioniert weder die Berechnung noch der "Clear" Button nicht mehr. Es kommt auch keine Fehlermeldung.

Bitte helft Mir
 
Zuletzt bearbeitet von einem Moderator:

randacek_pro

Mod | Forum

Moderationshinweis

Warum machst du dafür einen zweiten Thread auf und führst das nicht in deinem anderen, erst heute erstellen Thread weiter?

Ich verschiebe das mal dahin.
 
Zuletzt bearbeitet:

Duddle

Posting-Frequenz: 14µHz

AW: Hilfe bei mathematischer Berechnung

Auf einer einfachen html Seite funktioniert es, nun besteht meine Seite aber aus einem css template und wenn ich den Code einfüge funktioniert weder die Berechnung noch der "Clear" Button nicht mehr. Es kommt auch keine Fehlermeldung.
Naja, du musst schon das zeigen, was nicht funktioniert.
Entweder hast du es falsch eingefügt oder irgendein anderes Element stört den Ablauf. Ich tippe stark auf ersteres. Fehlermeldungen "erscheinen" auch nicht einfach, sondern werden in der Fehlerkonsole des Browsers mitgeführt.


Duddle
 

d4y

Pixel schupser

AW: Hilfe bei mathematischer Berechnung

Das ist der Code wo ich es eingefügt habe


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Underwater Magic Adhesive &amp; Sealant</title>
<meta name="keywords" content="css templates, fortune website, CSS, HTML" />
<meta name="description" content="Fortune Template is a free css template from templatemo.com" />
<link href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/templatemo_style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="uwm.js"></script>
</head>
<script type="text/javascript" src="uwm.js"></script>

<body>
<p>&nbsp;
</p>
<p>


<div id="templatemo_header_wrapper">
<div id="templatemo_header_panel">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p class="header_01">THE REAL SOLUTION FOR YOUR SWIMMING POOL</p>
</div></div>

<div id="templatemo_banner_wrapper">
<div id="templatemo_banner_panel">
</div>
</div>

<div id="templatemo_menu_wrapper">
<div id="templatemo_menu_panel">
<ul>
<li><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/index.html">Home</a></li>
<li><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/about_us.html" target="_parent">About</a></li>
<li><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/shop.html" target="_parent">Where to buy</a></li>
<li><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/Q_A.html" target="_parent" >Q&amp;A / Testimonials</a></li>
<li><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/Downloads.html"target="_parent" class="current">Downloads</a></li>
<li><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/contact.html" class="last">Contact</a></li>
</ul>
</div>
</div> <!-- end of menu -->

<div id="templatemo_content_wrapper">
<div id="templatemo_content_panel">

<div class="content_panel_3col_section margin_right_60">

<div class="header_01">Advertising</div>
<p><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/Underwater_Magic.pdf"target="_blank">• Brochure</a></p>
<p><a href="http://www.youtube.com/v/fQh-Tvr6yHw?hl=en&amp;fs=1"target="_blank"> • Video (new version comming soon)</a></p>
<p><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/Flyer_A5.pdf"target="_blank">• Flyer</a></p>
<p><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/Underwater_Magic_Tech.pdf"target="_blank">• Technical Data Sheet</a></p>
<p><a href="mailto:frank@underwatermagic.eu">• Safty Data Sheet (on request)</a></p>
<div class="p_section"></div>
</div>

<div class="content_panel_3col_section margin_right_60">
<div class="header_01">Foreign language</div>
<p><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/UWM_H.pdf"target="_blank">• Ελληνικά</a></p>
<p><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/UWM_F.pdf"target="_blank">• Française</a></p>
<p><a href="Profi-Glue_Ltd_Paperwork/Web_Design/Underwater_Magic_web/Россию.pdf"target="_blank">• Россию</a></p>
<p>&nbsp;</p>
<p><br />
</p>
</div>
<div class="content_panel_3col_section">
<div class="header_01">Calculator </div>
<p>Calculation is not including labour or material costs, or the missed fun having an empty pool.</p>
<p><strong>Pool length </strong>**
<input type="text" size="4" name="miles">
<strong> m</strong><br><br>**
<strong>Pool width</strong>**
<input type="text" size="4" name="gas">
<strong> m</strong><br><br>**
<strong>Pool depth </strong>
<input type="text" size="4" name="cost">
<strong> m</strong><br><br>**
<strong>Water price per m3</strong>
<input type="text" size="4" name="days">
<strong> Euro</strong><br><br>
<strong>Price for Chemicals</strong>
<input type="text" size="4" name="chem">
<strong> Euro</strong><br><br>
<input type="button" value="Calculate" onclick="d()">*<input type="Reset" value="Clear"><br><br>
<strong>Results</strong><br>
<textarea name="results" rows="5" cols="50" wrap style="border-width:0;overflow:hidden"onfocus="this.blur()">
</textarea>
</p>
<div class="p_section"></div>
</div>

<div class="margin_bottom_20"></div>
</div> <!-- end of content panel -->
</div> <!-- end of content wrapper -->

<div id="templatemo_footer_wrapper">
<div id="templatemo_footer_panel">
Copyright © 2012 frank@4yoursuccess.eu</div> <!-- end of footer panel -->
</div> <!-- end of footer wrapper-->

</body>
</html>
</p>
 

d4y

Pixel schupser

AW: Hilfe bei mathematischer Berechnung

Das css

/*
CSS Credit: http://www.templatemo.com
*/


body {
margin: 0;
padding: 0;
line-height: 1.5em;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #838fbb;
background: #08123a;
}

a:link, a:visited { color: #ffffff; text-decoration: none; font-weight: normal; }
a:active, a:hover { color: #99FFFF; text-decoration: underline; }

p {
margin: 0px;
padding: 0px;
}

img {
margin: 0px;
padding: 0px;
border: none;
}

.cleaner { clear: both; width: 100%; height: 0px; font-size: 0px; }

.margin_bottom_10 { float: left; width: 100%; height: 10px; font-size: 1px; }
.margin_bottom_20 { clear: both; width: 100%; height: 20px; font-size: 1px; }
.margin_bottom_30 { clear: both; width: 100%; height: 30px; font-size: 1px; }
.margin_bottom_40 { clear: both; width: 100%; height: 40px; font-size: 1px; }
.margin_bottom_50 { clear: both; width: 100%; height: 50px; font-size: 1px; }
.margin_bottom_60 { clear: both; width: 100%; height: 60px; font-size: 1px; }

.margin_right_10 { margin-right: 10px; }
.margin_right_60 { margin-right: 60px; }

/* header */
#templatemo_header_wrapper{
clear: both;
width: 100%;
height: 100px;
margin: 0 auto;
background: url(images/templatemo_header_repeat.jpg) repeat-x;
}

#templatemo_header_wrapper #templatemo_header_panel{
width: 980px;
height: 150px;
margin:0 auto;
color: #FFF;
text-align: center;
background: url(images/templatemo_header.jpg) no-repeat;
}

#templatemo_header_panel #templatemo_header{
padding-top: 50px;
font-size: 40px;
letter-spacing: 50px;
font-family: "Times New Roman", Times, serif;
}

#templatemo_header_panel #templatemo_tagline{
font-size: 20px;
padding: 20px 0px 5px 0px;
font-family: "Times New Roman", Times, serif;
}

/* end of header */

/* banner */
#templatemo_banner_wrapper{
clear: both;
width: 100%;
height: 240px;
margin: 0 auto;
background: url(images/templatemo_banner_repeat.jpg) repeat-x;
}

#templatemo_banner_wrapper #templatemo_banner_panel{
width: 980px;
height: 240px;
margin:0 auto;
text-align: center;
background: url(images/templatemo_banner.gif) no-repeat;
}

/* end of banner */

/* menu */
#templatemo_menu_wrapper{
width: 100%;
height: 90px;
margin: 0 auto;
background: url(images/templatemo_menu_bg_repeat.jpg) repeat-x;
}

#templatemo_menu_wrapper #templatemo_menu_panel{
width: 980px;
height: 90px;
margin:0 auto;
background: url(images/templatemo_menu_bg.jpg) no-repeat;
}

#templatemo_menu_panel ul {
float: left;
margin: 20px 0 0 10px;
padding: 0;
list-style: none;
}

#templatemo_menu_panel ul li{
display: inline;
}

#templatemo_menu_panel ul li a{
float: left;
width: 115px;
height: 52px;
padding: 8px 0 0 0;
margin-right: 40px;
font-size: 12px;
font-weight: bold;
text-align: center;
text-decoration: none;
color: #37a5dd;
background: url(images/templatemo_menu_button.png) no-repeat;
}

#templatemo_menu_panel li a:hover, #templatemo_menu_panel li .current{
color: #ffffff;
background: url(images/templatemo_menu_button_hover.png) no-repeat;
}

#templatemo_menu_panel li .last {
padding-right: 0px;
border-right: none;
}
/* end of menu */

/* content */
#templatemo_content_wrapper{
clear: both;
width: 100%;
margin: 0 auto;
background: url(images/templatemo_content_bg.jpg) repeat-x;
}

#templatemo_content_wrapper #templatemo_content_panel{
width: 960px;
padding: 40px 10px 0 10px;
margin:0 auto;
}

#templatemo_content_panel .content_panel_3col_section{
float: left;
width: 280px;
}

.content_panel_3col_section p{
text-align: justify;
margin-bottom: 10px;
}

.content_panel_3col_section p a {
color: #abbdfe;
}

.p_section {
color: #abbdfe;
text-align: justify;
text-decoration: underline;
margin-bottom: 10px;
}

.services {
margin: 20px 0 0 30px;
padding: 0px;
}

.services li{
padding-bottom: 10px;
}

.header_01 {
font-size: 18px;
color: #ffffff;
letter-spacing: 5px;
font-family: "Times New Roman", Times, serif;
font-weight: bold;
padding-bottom: 10px;
margin-bottom: 10px;
}

.image_box_01 {
padding: 4px;
background: #7a93d0;
margin-bottom: 10px;
}

.image_box_01 img {
border: 1px solid #fff;
}

.news_section {
clear: both;
}

.news_section .news_image {
float: left;
margin: 3px 0 0 0;
width: 82px;
padding: 4px;
background: #7a93d0;
}

.news_image img {
width: 80px;
height: 80px;
border: 1px solid #ffffff;
}

.news_section .news_content {
float: right;
width: 170px;
}

.news_section .news_title {
font-size: 12px;
font-weight: bold;
color: #abbdfe;
}


/* end of content */

/* footer */
#templatemo_footer_wrapper{
clear: both;
width: 100%;
margin: 0 auto;
border-top: 1px solid #203172;
background: #040a25;
}

#templatemo_footer_wrapper #templatemo_footer_panel{
width: 980px;
margin:0 auto;
padding: 15px 0;
text-align: center;
}

#templatemo_footer_panel a {
color: #abbdfe;
}

/* end of footer */
 

d4y

Pixel schupser

AW: Hilfe bei mathematischer Berechnung

die uwm.js



<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://www.javascriptsource.com
Created by: Matthew Ogden :: */

function d(){
var a = document.form1.miles.value;
var b = document.form1.gas.value;
var c = document.form1.days.value;
var costb = document.form1.chem.value;
var cost = document.form1.cost.value;
mpg=(a*b*c*cost)-(-costb);
gpd=(mpg-(-costb));
mpg= Math.round(mpg*10)/10;
gpy=gpd*365;
co=gpy*19.36;
cpy=gpy*cost;

gpy= Math.round(gpy*10)/10;
cpy= Math.round(cpy*100)/100;
co= Math.round(co);
document.form1.results.value="You spent "+mpg+" Euros to refill your pool.";
}
// End -->
 

Duddle

Posting-Frequenz: 14µHz

AW: Hilfe bei mathematischer Berechnung

Wie gesagt, die Fehlerkonsole hat sofort die Ursache aufgedeckt: "form1" wird nicht gefunden. Klar, du hast ja auch kein <form> mit Namen "form1", im Gegensatz zum funktionierenden Beispiel.
Du musst auch uwm.js nicht zweifach einbinden. Einmal im <head> reicht vollkommen aus.


Duddle
 

d4y

Pixel schupser

AW: Hilfe bei mathematischer Berechnung

Asche aus mein Haupt, die Zeile habe ich wohl beim einbinden gelöscht . Jetzt klappt es, wenn Du mal nach Zypern kommst lade ich `dich auf ein bis 10 Bier ein.

1000 Dank Duddle fuer die Hilfe und noch einen schönen Abend.

Frank
 
Bilder bitte hier hochladen und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Antworten auf deine Fragen:
Neues Thema erstellen

Willkommen auf PSD-Tutorials.de

In unseren Foren vernetzt du dich mit anderen Personen, um dich rund um die Themen Fotografie, Grafik, Gestaltung, Bildbearbeitung und 3D auszutauschen. Außerdem schalten wir für dich regelmäßig kostenlose Inhalte frei. Liebe Grüße senden dir die PSD-Gründer Stefan und Matthias Petri aus Waren an der Müritz. Hier erfährst du mehr über uns.

Stefan und Matthias Petri von PSD-Tutorials.de

Nächster neuer Gratisinhalt

03
Stunden
:
:
25
Minuten
:
:
19
Sekunden

Neueste Themen & Antworten

Flatrate für Tutorials, Assets, Vorlagen

Zurzeit aktive Besucher

Statistik des Forums

Themen
118.565
Beiträge
1.538.067
Mitglieder
67.488
Neuestes Mitglied
Andrew56524
Oben