Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6916643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:37:46+00:00 2026-05-27T09:37:46+00:00

I wrote a script in php. It’s very simple, it just multiplies a typed

  • 0

I wrote a script in php. It’s very simple, it just multiplies a typed in number and adds another number to it. But I don’t know how to convert it to js.

From the form on my html page, I submit the kilometers and the script calculates the cost of this ride (it’s a taxi company).

<form action="http://www.mydomain.de/action.php" class="box style" method="post" target="_blank">

<fieldset>
    <legend>Jetzt berechnen:</legend>
    <div style="float: left;"><label for="km">KM-Eingabe</label> <input name="km" type="Text"></div><div><input src="/images/berechnen.png" alt="berechnen" type="image"></div>
</fieldset>

</form>

The php script is this:

<p>
Sie haben angegeben, dass die geplante Fahrt <?php echo $_POST["km"];?> km betr&auml;gt.
<br />
Im  Tagtarif (werktags 06-22 Uhr) kostet die angefragte Fahrt <?php $km=$_POST["km"]; echo $km * 1.7 + 2.2; ?> EURO.
<br />
Im Nachttarif / Sonn- und Feiertags (werktags 22-06 Uhr) kostet die angefragte Fahrt <?php $km=$_POST["km"]; echo $km * 1.8 + 2.2;?> EURO.
</p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:37:46+00:00Added an answer on May 27, 2026 at 9:37 am

    You should probably learn the basics of Javascript, but hopefully this will help you get started

    <fieldset>
        <legend>Jetzt berechnen:</legend>
        <div style="float: left;"><label for="km">KM-Eingabe</label> <input id="txt_km" type="Text"></div><div><input src="/images/berechnen.png" alt="berechnen" type="image" onclick="submit()" /></div>
    </fieldset>
    
    <div id="resultDiv" style="display: none;">
       <p>
           Sie haben angegeben, dass die geplante Fahrt <span id="km"></span> km betr&auml;gt.
       <br />
           Im  Tagtarif (werktags 06-22 Uhr) kostet die angefragte Fahrt <span id="result"></span> EURO.
       <br />
       Im Nachttarif / Sonn- und Feiertags (werktags 22-06 Uhr) kostet die angefragte Fahrt <span id="result2" /> EURO.
       </p>
    </div>
    
    <script>
       function submit()
       {
           var km = parseInt(document.getElementById('txt_km').value);
           document.getElementById('km').innerHTML = km;
           document.getElementById('result').innerHTML = km * 1.7 + 2.2;
           document.getElementById('result2').innerHTML = km * 1.8 + 2.2;
           document.getElementById('resultDiv').style.display = '';
       }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just began learning PHP. I've installed php5 on Linux and wrote very simple
I just wrote a PHP login script, and what I'm trying to accomplish is
I wrote this php script to delete old files older than 24 hrs, but
Just a quick one - I wrote a php script recently that dynamically creates
I Wrote a small php script to convert string to HEX but i have
I already wrote a PHP script that allows users to upload images but I
I wrote a PHP script. When i try to use it throws an error.
I wrote a PHP script which will run every Monday using cron. In this
I wrote a script upload_songs.php When executed from the command line $ php upload_songs.php
I am trying to see what is wrong with a php script a wrote.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.