Hey Kasper,
det kan man sagtens.
Hvis du vil gøre det via din backend, kan du gøre brug af json.
HTML Form:
<select id="weeknr" name="weeknr">
<option value="01/2009">Uge 1 2009</option>
<option value="02/2009">Uge 2 2009</option>
<option value="03/2009">Uge 3 2009</option>
</select>
<input name="monday" id="monday" type="text" />
<input name="tuesday" id="tuesday" type="text" />
<input name="wednesday" id="wednesday" type="text" />
<input name="thursday" id="thursday" type="text" />
<input name="friday" id="friday" type="text" />
JQuery function:
$("#weeknr").bind("change", function(e){
$.getJSON("backend.php?weekyear=" + $("#weeknr").val(),
function(data){
$.each(data, function(i,item){
if (item.field == "monday") {
$("#monday").val(item.value);
} else if (item.field == "tuesday") {
$("#tuesday").val(item.value);
} else if (item.field == "wednesday") {
$("#wednesday").val(item.value);
} else if (item.field == "thursday") {
$("#thursday").val(item.value);
} else if (item.field == "friday") {
$("#friday").val(item.value);
}
});
});
});
PHP (backend.php)
<?php
list($week_number,$year) = split("/",$_GET['weekyear']);
$json = array(
array('field' => 'monday','value' => date('m/d/Y', strtotime($year."W".$week_number."1"))),
array('field' => 'tuesday','value' => date('m/d/Y', strtotime($year."W".$week_number."2"))),
array('field' => 'wednesday','value' => date('m/d/Y', strtotime($year."W".$week_number."3"))),
array('field' => 'thursday','value' => date('m/d/Y', strtotime($year."W".$week_number."4"))),
array('field' => 'friday','value' => date('m/d/Y', strtotime($year."W".$week_number."5")))
);
echo json_encode($json );
?>
Indlæg senest redigeret d. 28.07.2009 09:49 af Bruger #1330