Solved

Determining value of secondary input based upon primary

Posted on 2016-08-18
2
33 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 57

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 110

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
clicking to find my folders on wamp 8 43
Testrail - Active Directory integration. 4 34
How can I send attachment with mail 5 22
php time 12 21
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 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