PDA

View Full Version : Form - value from a javascript into MySQL



kaykills
July 4th, 2005, 04:19 PM
Hi,

I have a small calendar generated in javascript. The page it is on takes all the variables in the form and uploads it to a MySQL DB. I have wasted a lot of time trying to figure out how to get the date that the calendar outputs into mysql.

Example of the form:


<tr>
<td height="24">Title:
<input name="title" type="text" size="25" maxlength="25">
</td>
</tr>
<tr>
<td colspan="3">Sequence:&nbsp;
<input type="text" name="priority" size="30">
</td>
</tr>
<tr>
<td colspan="3">Expiry Date:&nbsp;
<script>DateInput('orderdate', true, 'MM/DD/YYYY')</script></td>
</tr>
<tr>
<td colspan="3">Document Name:&nbsp;
<input type="text" name="doc_name" size="30">
</td>
</tr>

How do I take the date from the javascript calendar and insert it like all my other variables??

Cheers
Michael

DDD
July 4th, 2005, 04:33 PM
this is a far shot and I do not think I fully understand your question but have you tried cookies? Then collect the cookie later?

kaykills
July 4th, 2005, 04:43 PM
I think I have made the question way more difficult then it is. I have tried cookies. That javascript is a calendar that you can choose a date from. All I want is that date to be able to be inserted into MySQL. Like any regular HTML form you can take the name of each input box etc. and insert it into mysql using PHP.

ex -

$query = "INSERT INTO publishdocs ( id, title, category, priority, expiry_date, doc_name )
values( '$id', '$title', '$category', '$priority', '$expiry_date', '$doc_name' )";

All I want is the output of that javascript calendar to be the expiry_date variable that get inserted into MySQL. Is that a bit more clear?? I think it is simple but just can't figure it out. If you think I would need a cookie, I wouldn't have the slightest clue where to start.

Michael

kaykills
July 4th, 2005, 04:45 PM
I think I have made the question way more difficult then it is. I have tried cookies.

I meant to say I have NOT tried a cookie.

kaykills
July 7th, 2005, 01:43 PM
hi,

does anyone have any thoughts on this??? Is it possible to wrap the javascript into an HTML form? I just need the output of the javascript (which works) to be able to insert into MySQL.

Cheers
Michael

hl
July 7th, 2005, 03:31 PM
this is a form, right?

put the action as $_SERVER['PHP_SELF'] and method as POST

then you put a php script like the following


<?
if(isset($_POST['submit'])){
process everything
}
?>


you understand what i mean?

edit:/ i think i understand what you want.

what you want to do is put an <input type="hidden" name="date" value="javascript:DateInput('orderdate', true, 'MM/DD/YYYY');">

kaykills
July 7th, 2005, 05:26 PM
this is a form, right?

put the action as $_SERVER['PHP_SELF'] and method as POST

then you put a php script like the following


<?
if(isset($_POST['submit'])){
process everything
}
?>


you understand what i mean?

edit:/ i think i understand what you want.

what you want to do is put an <input type="hidden" name="date" value="javascript:DateInput('orderdate', true, 'MM/DD/YYYY');">

that is exactly what I want... I have a hard time trying to explain things... I will test it out...... Thanks hLaLL... much appreciated.....

hl
July 7th, 2005, 05:51 PM
welcome. :)