• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML Would like output to appear without input?

tetherton

New Coder
This form is meant to be a trip cost calculator based on the users input, however I would like the output to appear automatically with the given input values.

HTML:
<html> 
<head> 
<title>Trip Cost Calculator</title>
</head> 
<body> 
 <p align="center" style="color: #00416a; font-weight: bold; font-size: 24px;">ACV<br>Humboldt County Airport</p> 
 <form style="background-color: #87ceeb; border: 3px solid #00416a; padding-left: 25px; padding-right: 25px; padding-bottom: 25px;" oninput="ACVTotal.value=parseInt(ACVair.value)+parseInt(ACVpark.value)*9 + 0 + 0;">
<br> 
    <label style="font-weight: bold;">ACV Air Fare Cost:</label><br>$ 
    <input type="number" name="ACVair" value="200"><br><br>
    <label style="font-weight: bold;">ACV Mileage:</label><br>$0<br><br>
<label style="font-weight: bold;">ACV Travel Time Cost:</label><br>$0<br><br>
    <label style="font-weight: bold;">Number of Days Parking at ACV ($9/day):</label><br>   
    <input type="number" name="ACVpark" value="5">
<br><br><br>
    <label style="color: #00416a; font-weight: bold; font-size: 18px;">Total Cost:</label><br><p style="color: #00416a; font-weight: bold; font-size: 18px;"> $ <output name="ACVTotal" style="color: #00416a; font-weight: bold; font-size: 18px;"></output></p> 
 </form> 
</body> 
</html>

Basically I want the page to load with the "Total Cost" already calculated with the preset inputs, and then change when the inputs change. I could not find an alternative form event to "oninput" that would output the "Total Cost" without user input. If anyone can give me some sort of workaround for this it would be much appreciated. And I hope this all makes sense, I have limited coding experience and feel I am making an easy task more difficult than it has to be.
 

Johna

King Coder
Staff Team
Guardian
This form is meant to be a trip cost calculator based on the users input, however I would like the output to appear automatically with the given input values.

HTML:
<html>
<head>
<title>Trip Cost Calculator</title>
</head>
<body>
 <p align="center" style="color: #00416a; font-weight: bold; font-size: 24px;">ACV<br>Humboldt County Airport</p>
 <form style="background-color: #87ceeb; border: 3px solid #00416a; padding-left: 25px; padding-right: 25px; padding-bottom: 25px;" oninput="ACVTotal.value=parseInt(ACVair.value)+parseInt(ACVpark.value)*9 + 0 + 0;">
<br>
    <label style="font-weight: bold;">ACV Air Fare Cost:</label><br>$
    <input type="number" name="ACVair" value="200"><br><br>
    <label style="font-weight: bold;">ACV Mileage:</label><br>$0<br><br>
<label style="font-weight: bold;">ACV Travel Time Cost:</label><br>$0<br><br>
    <label style="font-weight: bold;">Number of Days Parking at ACV ($9/day):</label><br>  
    <input type="number" name="ACVpark" value="5">
<br><br><br>
    <label style="color: #00416a; font-weight: bold; font-size: 18px;">Total Cost:</label><br><p style="color: #00416a; font-weight: bold; font-size: 18px;"> $ <output name="ACVTotal" style="color: #00416a; font-weight: bold; font-size: 18px;"></output></p>
 </form>
</body>
</html>

Basically I want the page to load with the "Total Cost" already calculated with the preset inputs, and then change when the inputs change. I could not find an alternative form event to "oninput" that would output the "Total Cost" without user input. If anyone can give me some sort of workaround for this it would be much appreciated. And I hope this all makes sense, I have limited coding experience and feel I am making an easy task more difficult than it has to be.
I'm not sure what you're trying to do, but you'll probably need JavaScript.
 

didlly

Well-Known Coder
Staff Team
Guardian
You mean that's what he wants, or that's what's happening and he doesn't want that?
That's what he wants. The page is a trip cost calculator based on the users inputs. However, when the page is loaded there are preset values. @tetherton wants the box where the total cost is shown to the user to have already calculated the total cost using the preset inputs.
 
Top