Theory Question--PHP and JavaScript

This will probably turn into more, but it starts as a theory and practicality question.

I am setting up a Tournament Entry Form using PHP.  The person who initially fills out the form will provide standard contact information (eventually dynamic from a registration database).  It is understood that this person is the first entry to the tournament.

Additionally, this person will be allowed to register up to seven additional entries to the tournament, with pertinent information, all of which is required if the entry is submitted.  They will tell us how many they want to register using a drop-down menu.

My intent is to use JavaScript to show the number of table rows necessary to collect the information about the additional entries.  I have designed a form that has the maximum number of table rows necessary.

Theory wise, how best should I design this so that if a table row is shown, the information is required, but if a table row is hidden, the information is no longer required, and the form will submit correctly?
DennisHackerAsked:
Who is Participating?
 
Ray PaseurCommented:
Not necessarily.  You MUST do the validation on the server side after the complete form has been submitted.  But there is nothing at all wrong with making this a good client experience, and if enabling or disabling the rows helps, then I am all for it.
0
 
leakim971PluritechnicianCommented:
disable all the fields of the hidden rows

0
 
DennisHackerAuthor Commented:
Disable?  What do you mean?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
leakim971PluritechnicianCommented:
<input type="textbox" disabled="disabled" name="textbox1" />
0
 
DennisHackerAuthor Commented:
OK.  So, start out with them all disabled, and maybe use a loop to change that value based on the drop-down input?
0
 
leakim971PluritechnicianCommented:
yes,

to remove : .removeAttribute("disabled");

http://www.w3schools.com/jsref/dom_obj_all.asp
0
 
DennisHackerAuthor Commented:
I will give that a shot.  I'm working on it tonight.  I'll let you know how it goes.  Thanks!
0
 
Ray PaseurCommented:
On the server side of things you will not know whether the row was enabled or disabled.  You can use empty() to see if all the fields in the row are empty.
0
 
DennisHackerAuthor Commented:
Ray:

If I understand correctly, I can use JavaScript to hide or show table rows based on class tags.  Is it better to just worry about the server side and not mess with enabling or disabling the rows?
0
 
DennisHackerAuthor Commented:
Thank you.  This form will be a stepping-stone to more complicated Tournament Entry Forms for another client.  It's critical that I get this correct on a singles entry, because it will be more complicated later when I deal with Team, Doubles, Singles, and All-Events for a number of groups.
0
 
DennisHackerAuthor Commented:
Still working on this guys.  I've got another question posted about what I've come up with so far.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.