Welcome to the Virtual Education Wiki ~ Open Education Wiki

Form:Test calculation form: Difference between revisions

From Virtual Education Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<form>
<noinclude>
  <label for="num1">Number 1:</label>
This is the 'Calculation' form. The form is used to perform simple calculations.
  <input name="num1" type="number" />
 
  <br>
'''''After several iterations with ChatGPT it still does not work.'''''
  <label for="num2">Number 2:</label>
</noinclude>
  <input name="num2" type="number" />
<includeonly>
  <br>
{{{info|calculation form}}}
  <label for="operator">Operator:</label>
{{{for template|Calculation}}}
  <select name="operator">
Enter two numbers and select an operator below.
    <option value="+">Addition</option>
 
    <option value="-">Subtraction</option>
{| class="formtable"
    <option value="*">Multiplication</option>
! Number 1:
    <option value="/">Division</option>
| {{{field|number1}}}
  </select>
|-
  <br>
! Number 2:
  <input type="submit" value="Calculate">
| {{{field|number2}}}
  <br>
|-
  {{#ifexpr: {{{num1|0}}} AND {{{num2|0}}}
! Operator:
    |Result:  
| {{{field|operator|input type=select|values=+,-,*,/}}}
    {{#switch: {{{operator}}}
|}
      |+ = {{#expr: {{{num1}}} + {{{num2}}}}}
{{{end template}}}
      |- = {{#expr: {{{num1}}} - {{{num2}}}}}
 
      |* = {{#expr: {{{num1}}} * {{{num2}}}}}
(You can see the form this query uses at [[Form:Calculation]], and the template it uses at [[Template:Calculation]].)
      |/ = {{#expr: {{{num1}}} / {{{num2}}}}}
 
    }}
{{#ifexpr: {{{number1|0}}} AND {{{number2|0}}}
  }}
| Result: {{#switch: {{{operator}}}
</form>
  |+ = {{#expr: {{{number1}}} + {{{number2}}}}}
  |- = {{#expr: {{{number1}}} - {{{number2}}}}}
  |* = {{#expr: {{{number1}}} * {{{number2}}}}}
  |/ = {{#expr: {{{number1}}} / {{{number2}}}}}
}}
}}
</includeonly>

Latest revision as of 13:54, 21 April 2023

This is the 'Calculation' form. The form is used to perform simple calculations.

After several iterations with ChatGPT it still does not work.