Apitos
2010-11-15 17:14:33 UTC
Bonjour à tous,
J'aimerais récupérer deux valeurs d'un formulaire lors de l'évènement
onSubmit(), pour les injecter comme paramètres dans la fonction
javascript loadcalandar(month,year).
J'ai utiliser :
this.month.value pour le champ month
et
this.year.value pour le champ year.
mais en retour je n'ai que des valeurs vides :
loadCalendar("","");
<?php
// define array
$montharray = array('', 'January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September', 'October', 'November',
'December');
function years($selected=''){
$yearslist = "<select size='1' name='year'>";
for ( $y=1970; $y <2022; $y++ ){
if($selected == $y) $yearslist .= "<option selected value='$y'>$y</
option>";
else $yearslist .= "<option value='$y'>$y</option>";
}
$yearslist .= "</select>";
return $yearslist;
}
function months($selected='',$montharray){
$monthslist = "<select size='1' name='month'>";
for ( $m=1; $m <13; $m++ ){
if($selected == $m) $monthslist .= "<option selected value='$m'>
$montharray[$i]</option>";
else $monthslist .= "<option value='$m'>$montharray[$i]</option>";
}
$monthslist .= "</select>";
return $monthslist;
}
funcion printout(){
$output ='<div id="select_date">';
$output .='<form name="selectmonthyear" action=""/>';
$output .= months(date('n'));
$output .= years(date('Y'));
$output .='<input type="submit"
onSubmit="loadCalendar(\"this.month.value\",\"this.year.value
\");return false;" value="Go"/>';
$output .='</form></div>';
}
printout();
?>
J'aimerais récupérer deux valeurs d'un formulaire lors de l'évènement
onSubmit(), pour les injecter comme paramètres dans la fonction
javascript loadcalandar(month,year).
J'ai utiliser :
this.month.value pour le champ month
et
this.year.value pour le champ year.
mais en retour je n'ai que des valeurs vides :
loadCalendar("","");
<?php
// define array
$montharray = array('', 'January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September', 'October', 'November',
'December');
function years($selected=''){
$yearslist = "<select size='1' name='year'>";
for ( $y=1970; $y <2022; $y++ ){
if($selected == $y) $yearslist .= "<option selected value='$y'>$y</
option>";
else $yearslist .= "<option value='$y'>$y</option>";
}
$yearslist .= "</select>";
return $yearslist;
}
function months($selected='',$montharray){
$monthslist = "<select size='1' name='month'>";
for ( $m=1; $m <13; $m++ ){
if($selected == $m) $monthslist .= "<option selected value='$m'>
$montharray[$i]</option>";
else $monthslist .= "<option value='$m'>$montharray[$i]</option>";
}
$monthslist .= "</select>";
return $monthslist;
}
funcion printout(){
$output ='<div id="select_date">';
$output .='<form name="selectmonthyear" action=""/>';
$output .= months(date('n'));
$output .= years(date('Y'));
$output .='<input type="submit"
onSubmit="loadCalendar(\"this.month.value\",\"this.year.value
\");return false;" value="Go"/>';
$output .='</form></div>';
}
printout();
?>