Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Determining value of secondary input based upon primary

Posted on 2016-08-18
2
Medium Priority
?
38 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 59

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 111

Accepted Solution

by:
Ray Paseur earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

647 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