Hello Experts,
I am not sure what would be considered best practice, and what is recommended. I am new to programming and new to PHP in general. I am self-taught, so I am sure my code is vulnerable in areas, etc., and I am sure I am not doing things correctly, per industry-standard. But, I enjoy being creative.
I am working on a website at the moment. The website is designed to create 1 of 4 arrest PDFs, based off the user's input, when asked "What type of arrest would you like to generate?" Each arrest varies in size and each arrest differs from the data collected in order to create it. For instance, the arrest type of "Juvenile Civil Citation" does not collect the person's social security number, eye color, hair color, scars, marks, or tattoos, whereas the arrest type of "NTA" does collect all of that information. Rather than have one massive HTML form which contains unnecessary fields (based off my previous explanation), I would like to have a specific form for each arrest type which only contains the input fields necessary for that type of arrest. Upon submitting the form, the form is processed by PHP and creates the corresponding PDF via FPDF.
Ultimately, I would like to dynamically load each form into the web browser after the end user selects the corresponding arrest from an HTML select element. However, it might be easier to just create four separate HTML pages which have customized forms and then link to each page...
I believe Javascript or JScript is able to accomplish my goal. However, I am reluctant to learn a new programming language when I am just in my infancy stages of learning php...
Any ideas/suggestions?
Exactly, I once had a project to create my own personal blog which had four partial views with the same structure and hardcoded links, etc. So I dynamically loaded each of them (instead of hardcoding them to the main view, which I can change what's needed at a different portion. this is some sort of separation of concerns) with jQuery's html() method attached to the element.
This strategy is like programming, each big repetitive chunk is being chopped down to a recallable function. Same concept goes to html, when you have a big chunk of markup, consider splitting it into smaller partial views (it doesn't have to be strictly asp.net, it could be just plain html markup files) and load them with the method I previously mentioned.
jQuery html() method, it injects partial views into the content markup by a tag.