• Hi There, I’m hoping someone can help me. I want to create a simple form where kids can enter in a word or number which they have found as a result of a puzzle they’ve solved physically. When they enter the code into a form field it will display a clue/hint etc corresponding to that code or it will display text saying “not a valid entry” etc… I want to be able to have different words or number producing different statement or pictures. For example a kid might enter “1234” and it will show text saying “check the freezer for your next clue” or enter “cat” and it will show a picture of the letterbox… Does anyone know a simple way to achieve this? I don’t mind learning some coding if required, it’s been a while but I do know some stuff and always happy to learn if someone can point me in the right direction.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could modify an existing theme template to include an input field within a HTML form element, along with a submit button. The form would submit back to the same page. Template code could get the submitted value and output a response in return. If there are not too many possible inputs, it could all be coded within the template as a series of conditionals or a switch/case structure. The default response if there is no match would be the “not a valid entry” response. If there is no response at all in the URL, output the input fields within their form, prompting the child to enter something.

    If there are too many different possible inputs for this to be manageable in template code, The data could reside in a DB table. It could be a custom table, basically a flat lookup table, or you could utilize a page’s custom fields to store inputs and responses. Input would be the custom field key, and response would be the value. Your template would query for the lookup entry or custom field key and possibly get a value in return which would be output on the form response page. If nothing is returned, it’s not a valid entry.

    Name your template file in accordance with template hierarchy to have it be used for a specific page. The page mainly serves as a way to get a specific template based on the page’s title slug. It needn’t have any content in the conventional sense, though it could if you like. The template mainly needs to output a form field or a response, or both.

Viewing 1 replies (of 1 total)
  • The topic ‘Conditional statement help’ is closed to new replies.