Solved

Determining value of secondary input based upon primary

Posted on 2016-08-18
2
30 Views
Last Modified: 2016-08-31
Okay, so I've got a stupid question.  Here's a model of what I'm working with.

https://jsfiddle.net/5bxjxwj4/2/

There's a webform that's dynamically created based upon database entries (course 1, course 2, ... course X).  The user selects the a number of tickets based upon the select next to the price.

What would be the best way of determining which price has been selected on form submission?
0
Comment
Question by:erzoolander
2 Comments
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 41761577
First problem - duplicate id's - id's must be unique on the page.
Second problem - duplicate names - the second one will overwrite the first ... actually the submission will be something like
adnum_1=4&adnum_1=2

Open in new window

But even if you process the raw POST you can't tell which is which.

Just give your selects different names like
adnum_68 and adnum_70
That way you can check the values of those variables when they are submitted to see how many of each ticket was requested.
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41762481
A general design for something like this would be a "Course Object."  This object would live in your database (probably in an active record design).  Each Course would be represented by one object.  The object would have associated information about the course, for example, its "id" and title, cost, duration, schedule, number of seats, number of available seats, etc.

The PHP script that builds the HTML form would use the Course Object to create the HTML.  Since the course "id" is unique, it can be used as a suffix for the form input control names.  This will give you a way to get names like adnum_68  and adnum_70  as Julian suggests.

If you're getting into course and class scheduling, the fundamentals of a "resource scheduling calendar" will come into play.  This article contains an example showing the design we use to schedule finite resources.  See Practical Application #12.
https://www.experts-exchange.com/articles/20920/Handling-Time-and-Date-in-PHP-and-MySQL-OOP-Version.html
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question