User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,563 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,738 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 978 | Replies: 4 | Solved
Reply
Join Date: Mar 2005
Posts: 64
Reputation: atrusmre is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
atrusmre's Avatar
atrusmre atrusmre is offline Offline
Junior Poster in Training

Question Dynamic Forms

  #1  
Oct 25th, 2007
Ok this may be a stupid questions. Is there a way to make a dynamic form? For example, if I wanted to create a form that took a users birthday, how do I make it so it would change the number of days in the month to correspond to the month selected. (with out having to submit the form). So if a user was to select their birth month as February it would put the number of days to 28. Any Ideas?

Thanx in advance

~Atrus
Last edited by atrusmre : Oct 25th, 2007 at 11:24 am.
Thanx,
Atrus
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Dynamic Forms

  #2  
Oct 25th, 2007
javascript obviously.

Javascript has a little quirk where a date of zero will set the date to be the last day of the previous month. Likewise is there are 30 days in a month and you set a date of 31 it will be the 1st day of the next month, a date of 40 would be the 10th day of the next month. This can lead to some very weird funkiness if you're not careful but we can definitely exploit this for a useful prototype which will give us the number of days in a specific month. We'll do this up as a prototype so it's available to all our Dates.
Date.prototype.daysInMonth = function () {
   return new Date(this.getFullYear(), this.getMonth()+1, 0).getDate()
}

var d = new Date();
document.writeln('Number of days in this month: '+d.daysInMonth());

This came from here:

http://www.hunlock.com/blogs/Javascr...lete_Reference

All you need to do is substitute this.getMonth() in the prototype with document.getElementById("usermonthdropdown").value
Last edited by hollystyles : Oct 25th, 2007 at 11:43 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 251
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 12
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Dynamic Forms

  #3  
Oct 25th, 2007
nice topic
Do a favour, leave me alone
Reply With Quote  
Join Date: Mar 2005
Posts: 64
Reputation: atrusmre is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
atrusmre's Avatar
atrusmre atrusmre is offline Offline
Junior Poster in Training

Re: Dynamic Forms

  #4  
Oct 25th, 2007
Originally Posted by hollystyles View Post
javascript obviously.


Is there anyway of doing it w/o java?

~Atrus
Thanx,
Atrus
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Dynamic Forms

  #5  
Oct 26th, 2007
>Is there anyway of doing it w/o java?
We *are* doing it without java! Javascript is *NOT* Java tsk.

I cannot think of any better solution than using javascript. You have to execute SOMETHING on the client if you don't want to postback server-side to do it. To do that you need to run a program. The options are:

Javascript (By far the most common sense solution)
Java Applet (overkill)
VBScript (IE browsers Only)
ActiveX Control (IE Only and overkill)
Last edited by hollystyles : Oct 26th, 2007 at 3:20 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 10:03 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC