can u help me with this one?
can you gve me a sample code on how to add 2 values of textbox using php ?

Well, i think this is what you need.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<input type="checkbox" name="q1[]" value="a" />value1<br>
<input type="checkbox" name="q1[]" value="b" />value2<br>
<input type="checkbox" name="q1[]" value="c" />value3<br>
<input type="submit" value = "submit" />

And then, you use something like :

$variable = $_POST['q1'];

or you define a variable that will go trought your values from q1 vector. Something like this:

for($i = 0; $i < count($_POST['q1']); $i++) //you are going trought the vector
$aux = $aux.$_POST['q1'][$i] //here, the variable $aux will get the options you have in your textbox.

I hope it helped you a bit, i am not a pro with php. Regards, Darius.


if you want in JS use the below code

<SCRIPT language = JavaScript>

function calculate() {
	document.getElementById("total").value =
    parseFloat(document.getElementById("one").value) +

<input name="one" type="text" value ="" size="5">

<input name="two" type="text" value ="" size="5" onChange="calculate()">
Total: <input name="total" type="text" value ="" size="5">

I want to add up 2 dates and show the total days.
I have 2 textbox, Starting Date in 1st textbox and End Date in 2nd text box.
And I have to show toatl days in 3rd Textbox.
Like 2013-10-01 + 2013-10-03 = 2

Thanks & Regards,
Shamil Ahmed P


Try this

<form name="dateForm" id="dateForm" method="post" action="#">
<label for="txtStartingDate">Starting Date</label>
<input type="text" name="txtStartingDate" id="txtStartingDate" value="<?php  echo (isset($_POST['txtStartingDate'])) ? $_POST['txtStartingDate'] : ""; ?>" />
<label for="txtEndDate">End Date</label>
<input type="text" name="txtEndDate" id="txtEndDate" value="<?php  echo (isset($_POST['txtEndDate'])) ? $_POST['txtEndDate'] : ""; ?>"  />
<input type="submit" name="sbtbtn" value="Submit" /> 

$diff = abs(strtotime($_POST['txtStartingDate']) - strtotime($_POST['txtEndDate']));
$days = floor(($diff)/ (60*60*24));
<label for="txtResult">Result</label>
<input type="text" name="txtResult" id="txtResult" value="<?php echo $days; ?>"  />


using single textbox ,add two numbers through selector and function in PHP