Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Theory Question--PHP and JavaScript

Posted on 2011-10-04
11
Medium Priority
?
275 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:DennisHacker
  • 6
  • 3
  • 2
11 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 36913567
disable all the fields of the hidden rows

0
 

Author Comment

by:DennisHacker
ID: 36913576
Disable?  What do you mean?
0
 
LVL 83

Expert Comment

by:leakim971
ID: 36913581
<input type="textbox" disabled="disabled" name="textbox1" />
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:DennisHacker
ID: 36913602
OK.  So, start out with them all disabled, and maybe use a loop to change that value based on the drop-down input?
0
 
LVL 83

Expert Comment

by:leakim971
ID: 36913627
yes,

to remove : .removeAttribute("disabled");

http://www.w3schools.com/jsref/dom_obj_all.asp
0
 

Author Comment

by:DennisHacker
ID: 36913640
I will give that a shot.  I'm working on it tonight.  I'll let you know how it goes.  Thanks!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36913685
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
 

Author Comment

by:DennisHacker
ID: 36913726
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
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 36913758
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
 

Author Comment

by:DennisHacker
ID: 36913773
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
 

Author Comment

by:DennisHacker
ID: 37021810
Still working on this guys.  I've got another question posted about what I've come up with so far.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

581 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