Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien
Toon posts:

HTML JAVA datum form

Pagina: 1
Acties:
  • 286 views

Verwijderd

Topicstarter
Hallo leden van tweakers,

pas geleden ben ik tegen een probleempje opgelopen met een datum formulier. Ik wil dat mensen afspraken kunnen maken met mij via een html formulier. Nou heb ik een java code gevonden waarmee mensen een datum kunnen selecteren via multiple choice. Alleen staat er bij elke maand als laatste dag "31" . Hoe kan ik het aanpassen zodat het voor elk maand goed gepast is? ( bijv dat het 29 februari op z'n hoogst kan worden wanneer ik februari kies en geen 31 )

Alvast bedankt voor jullie reacties!

mvg,
Misha

  • jessy100
  • Registratie: November 2010
  • Laatst online: 24-11 23:12
wat heb je zelf al gevonden en geprobeerd? ik adviseer je om even de beleidsregels door te nemen want we helpen je graag, maar eigen inzet is ook wel gewenst.
je lijkt me niet echt heel kundig aangezien je code hebt gevonden.(no offence, maar laat talen die je niet kent links liggen en ga niet zomaar een code overnemen).

en je hebt het over multiple choice, word daarmee bedoelt dat alle data dmv radioboxes onder elkaar staan? of staat ze in select options?

code voorbeeldje zou handig zijn.

[ Voor 37% gewijzigd door jessy100 op 23-02-2012 16:34 ]


Verwijderd

Topicstarter
Dit is wat ik in <head> heb gezet, zoals het stond vanaf de web waarin ik het gekopieerd heb. En ja het klopt dat ik nieuw ben met java, maar ik gebruik het ook nooit, tot nu dan :) En ik bedoel select options

Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
var DaysInMonth = 31;
if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4)) DaysInMonth = 28;
if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4)) DaysInMonth = 29;
return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
DaysObject = eval("document.Form1." + Which + "Day");
MonthObject = eval("document.Form1." + Which + "Month");
YearObject = eval("document.Form1." + Which + "Year");

Month = MonthObject[MonthObject.selectedIndex].text;
Year = YearObject[YearObject.selectedIndex].text;

DaysForThisSelection = DaysInMonth(Month, Year);
CurrentDaysInSelection = DaysObject.length;
if (CurrentDaysInSelection > DaysForThisSelection)
{
for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
{
DaysObject.options[DaysObject.options.length - 1] = null
}
}
if (DaysForThisSelection > CurrentDaysInSelection)
{
for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
{
NewOption = new Option(DaysObject.options.length + 1);
DaysObject.add(NewOption);
}
}
if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which)
{
DaysObject = eval("document.Form1." + Which + "Day");
MonthObject = eval("document.Form1." + Which + "Month");
YearObject = eval("document.Form1." + Which + "Year");

YearObject[0].selected = true;
MonthObject[NowMonth].selected = true;

ChangeOptionDays(Which);

DaysObject[NowDay-1].selected = true;
}

//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
line = "";
for (i=0; i<YearsAhead; i++)
{
line += "<OPTION>";
line += NowYear + i;
}
return line;
}

  • jessy100
  • Registratie: November 2010
  • Laatst online: 24-11 23:12
Verwijderd schreef op donderdag 23 februari 2012 @ 16:41:


var DaysInMonth = 31;
if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4)) DaysInMonth = 28;
if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4)) DaysInMonth = 29;
return DaysInMonth;
lees je code eens aandachtig door. er staat als een optie voor days in month. dit moet met de minste kennis op te lossen zijn op toe te passen. volgende keer ook even code tags gebruiken. en bestudeer een code op zijn minst voordat je heb klakkeloos overneemt.

[ Voor 59% gewijzigd door jessy100 op 23-02-2012 16:44 ]


  • Cartman!
  • Registratie: April 2000
  • Niet online
Je bedoelt Javascript in plaats van Java, misschien vind je dan meer resultaten in Google als je zoekt naar hulp ;)

Verwijderd

Topicstarter
var DaysInMonth = 31;
if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4)) DaysInMonth = 28;
if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4)) DaysInMonth = 29;
return DaysInMonth;

Dit heb ik zelf handmatig aangepast, ik wil dat het gewoon goed werkt, sorry als ik voor irritaties zorg.

Dankje voor je opmerking cartman, ik zal het zo aanpassen en ook verder googlen :)

  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 24-11 18:26

Creepy

Tactical Espionage Splatterer

Wat je wilt is prima, maar wat wij willen is dat je Het algemeen beleid #quickstart even leest en je daar aan houdt. Je code dumpen en hopen dat wij het voor jou gaan fixen is niet de bedoeling. Het is hier geen helpdesk ondanks dat er mensen zijn die het zo (willen) gebruiken.

Dus probeer nu eerst zelf eens je probleem op te lossen en als dat dan niet lukt op z'n minst aan te geven wat je nu zelf al hebt geprobeerd en wat er niet mee lukte. Als het probleem zit in code die je van een ander hebt, probeer dan eerst daar even support te vragen ;)

[ Voor 30% gewijzigd door Creepy op 23-02-2012 16:57 ]

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney

Pagina: 1

Dit topic is gesloten.