We help IT Professionals succeed at work.
Get Started

posting a javascript variable into a database

amchugh89
amchugh89 asked
on
654 Views
Last Modified: 2013-12-12
I need to insert a value (date selected from a javascript calendar) into php

i have php code that inserts a few things into a database:

 mysql_query("INSERT INTO `database`.`table` (field1 ,
field2 ,
field3,
date
)
VALUES ('$_POST[thing_1]','$_POST[thing_2]','$_POST[thing_3]','$_POST[javascript_date ]')");

my query works for thing_1, thing_2 and thing_3, which i have gotten from standard html elements like textboxes and dropdown list - but i am having trouble posting to the 'date' column.
they are all within the same form but...
unlike the other things i posted, javascript_date is selected from a fancy js calendar.

the code for the calendar is given below and the  link to the demo is given at the bottom of
http://javascriptcalendar.org/javascript-date-picker.php

<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />

<script type="text/javascript">
	window.onload = function(){
		
		
		g_globalObject = new JsDatePick({
			useMode:1,
			isStripped:true,
			target:"div3_example"
			/*selectedDate:{				This is an example of what the full configuration offers.
				day:5,						For full documentation about these settings please see the full version of the code.
				month:9,
				year:2006
			},
			yearsRange:[1978,2020],
			limitToToday:false,
			cellColorScheme:"beige",
			dateFormat:"%m-%d-%Y",
			imgPath:"img/",
			weekStartDay:1*/
		});		
		
		g_globalObject.setOnSelectedDelegate(function(){
			var obj = g_globalObject.getSelectedDay();

			document.getElementById("div3_example_result").innerHTML = obj.month + "/" + obj.day + "/" + obj.year;
		});
		



		
	};
</script>
</head>
<body>
	<h3>Choose Date</h3>
    


    <div id="div3_example" style="margin:10px 0 0px 0; border:dashed 1px black; width:205px; height:205px;">
    	
    </div>

    <div id="div3_example_result" style="height:20px; line-height:20px; width:80px; margin:10px 0 20px 0; border:dashed 1px black;"></div>

</body>
</html>

Open in new window

Comment
Watch Question
Web Architect
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE