Instead of implenting a prefabricated calender on my site, I tried a different route. I built a simple form where the user picks time and date.
Now, what I need to do is to secure a dynamic changing of the <select> tag carrying the values for days in the month, based on what information the user has put into the <select> tag carrying the values for the month. This should be logical, as it should not be possible to choose ie. the 31st of June, as there's no such date. I hope you understand what I need.
So let's dive into what code I have so far.
My PHP looks like this for the $_GET:
if($_GET['input_text'])
{
$month_pick = $_GET['input_text'];
echo $month_pick;
return;
}
My for-loop running the <option> tags within my <select> tag for the date of the month looks like this:
for($i = 0; $i < date('d', mktime(0, 0, 0, $month_pick, 0, $year)); $i++)
The variable "$year" is just a simple date function choosing this year.
My AJAX looks like this:
function test()
{
var input_text = document.getElementById("input_text").value;
var url = "calendar.php?input_text=" + escape(input_text);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = update;
xmlHttp.send();
}
The function update is for test usage, where I have a second field outputting the echoed value, so I can keep check on how the transaction is going.
Any suggestions on how I can crack this issue? My problem seems to be that the "$month_pick" variable doesn't change dynamically within the for-loop, therefore not restricting the amount of loops with the new month chosen. The test field I set up with the update function is working though, I am getting the name of the month I pick from the drop-down menu in the month <select> tag.
The month tag looks like this:
<select name="input_text" onchange="test();" id="input_text">

New Topic/Question
Reply



MultiQuote




|