Can someone guide me in the right direction? I have a drop down with values of 1 through 14 (1 = 1 day, 2 = 2 days, 3 = 3 days, ect). The onchange the drop down should calculate the days starting from today. If today is 4/1/08 and the user selects 3 then the output should show 4/4/08. However, my problem is that the date is not changing.
[HTML]<select name="lstPrpTyp eDesc" id="lstPrpTypeD esc" onblur="validat e(this.value, this.id)" onchange="????" >[/HTML]
[PHP]<?php
$PostOptions = array("0" => "[Select]",
"1" => "3",
"2" => "4",
"3" => "5",
"4" => "6",
"5" => "7",
"6" => "14");
$current = time();
$postdays=$_SES SION['values']['lstPost'];
$exp_date = time() + (86400 * $postdays);
$expdate = date('l, m-d-Y H:i:s A', $exp_date);
echo $expdate;?>[/PHP] - function ajaxtime(val) {var req;try{req = new XMLHttpRequest();} catch (e){try{req = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{req = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){alert("Please Update Your Browser");return false;}}}req.onreadystatechange = function(){if(req.readyState == 4){document.getElementById('response').innerHTML = req.responseText;}}req.open("GET", "time.php", true);req.send(null);}
12 1605
Some small changes made, both to script and PHP file.
This works for me (IE and FF):
PHP: -
<?php
-
$postdays = $_REQUEST['lstPost'];
-
$exp_date = time() + (86400 * $postdays);
-
$expdate = date('l, m-d-Y H:i:s A', $exp_date);
-
echo $expdate;
-
?>
-
HTML / JS: -
<select name="lstPrpTypeDesc" id="lstPrpTypeDesc" onchange="ajaxtime(this.value)">
-
<option value="3">3</option>
-
<option value="4">4</option>
-
<option value="5">5</option>
-
<option value="6">6</option>
-
<option value="7">7</option>
-
<option value="14">14</option>
-
</select>
-
-
<div id="response"> </div>
-
-
<script type="text/javascript" language="JavaScript">
-
-
function ajaxtime(val) {
-
var req;
-
try{
-
req = new XMLHttpRequest();
-
} catch (e) {
-
try {
-
req = new ActiveXObject("Msxml2.XMLHTTP");
-
} catch (e) {
-
try{
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
} catch (e) {
-
alert("Please Update Your Browser");
-
return false;
-
}
-
}
-
}
-
req.onreadystatechange = function() {
-
if(req.readyState == 4){
-
document.getElementById('response').innerHTML = req.responseText;
-
}
-
}
-
req.open("POST", "time.php?lstPost="+val, true);
-
req.send(null);
-
}
-
-
</script>
-
Thanks JazzSingerNL I will give that a shot
JazzSingerNL it woks like a charm. However, I have 1 more question. How would I store the value of div id="response" into a database?
acoder 16,027
Recognized Expert Moderator MVP
Make it into a form field and submit the form to a server-side script which saves the data to the database. Alternatively, use a hidden field.
You could also do this via Ajax or even when making the original date request (if appropriate).
Make it into a form field and submit the form to a server-side script which saves the data to the database. Alternatively, use a hidden field.
You could also do this via Ajax or even when making the original date request (if appropriate).
Acoder - I'm not sure what you mean.
acoder 16,027
Recognized Expert Moderator MVP
Which part do you not understand?
With your current code, an easy solution would be to set a hidden field to the value of the response, so that it can be submitted.
Sorry I don't get it?
[HTML]input name="txtExp" id="txtExp" value="<div id="response"> </div>"[/HTML]
I have the following code but it seems the hidden field is always 1 step behind. How do I go about getting the current value?
[HTML]<div id="response">< input type="hidden" name="txtExp" value="<?php echo $_SESSION['txtExp']; ?>"/></div>[/HTML]
acoder 16,027
Recognized Expert Moderator MVP
Sorry I don't get it?
[HTML]input name="txtExp" id="txtExp" value="<div id="response"> </div>"[/HTML]
No, the value should be equal to the content of the div, e.g. its innerHTML, not the div itself.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: CSharpguy |
last post by:
I'm trying to populate a drop down with dates from a data field in my data
base but I want the format like MM/dd/yyyy instead of 1/1/2006 12:00 PM
How can I my date to show as 1/1/2006?
I'm populating the dropdown via a dataset and doing a:
string time =
Convert.ToDateTime(dataset.tables.rows.toString()).ToShortDateString();
dropdown.datatexfield = time;
dropdown.datavaluefield = time
dropdown.databind();
|
by: trint |
last post by:
In my winform, I have 3 dropdown style comboboxes. I want the program
to always start with
the "Todays date" to be selected in the three comboboxes.
example of todays date selected by using all three combo dropdown
boxes:
cboDropDownStyle1 = June | cboDropDownStyle2 = 26 | cboDropDownStyle3
= 2007
Those items already exist in the comboboxes, I just want them
|
by: Panna |
last post by:
Hey there
I am using phpMyAdmin and MySQL to develop a dbase application.
I have a dropdown menu on one of the pages which gets populated automatically with data from a table in the database. The code for this is as follows:
$sql3="SELECT ID, UploadDate FROM Telkom";
$result2=mysql_query($sql3);
$options="";
|
by: natalievl |
last post by:
Hi,
I have a Drop Down List that is being populated by a sql server database with the following query...
sqlSchedule = ("SELECT cast(DATE_FROM as smalldatetime) AS DATE from EVENTS WHERE ITEMID = '" + txtid + "'");
The DropDown is populated with '30/09/2007 12:00:00 AM'
Can someone please tell me how to change the date format in the dropdown to 30/09/2007.
|
by: tabm2004 |
last post by:
I have an ASP main page with date fields dropdown like
From date Date .. Month .....Year
To date Date.. Month..... Year
whenever i open mainpage.asp in the browser, i am needed to select the To & From dates. Instead of that i want the system date should be generated automatically in the dropdown boxes. Plz advice the code for this.
| |
by: zion4ever |
last post by:
Hello good people,
Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
|
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== |
last post by:
I have a VS 2008 ASP.NET webform that has a reportview tag on it, accessing
an .RLDC report in local report.
The columns for the report are essentially:
Month Item #1 Item#2 Item#3
I would like to add a checkbox or dropdown control to the .RLDC and have
Item #1, Item #2, or Item #3 display conditionally based on a checkbox being
clicked or a dropdown value being selected.
|
by: microsoftboy |
last post by:
Hi,
Using the following selection criteria, I am able to list the data from mysql db, but I would like to provide the following options for users: Select All Data, Select None. I am not sure if this is possiible. Any help would be greatly appreciated.
Here's my code
<h4>SEARCH</h4>
<form action="<?php echo $_SERVER ?>" method = "post" target = "right">
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |