Hi
Im trying to create a form that will add two numbers and input the answer automatically into a text box. Please help.
Basically, I have created two text boxes called length and width and another called total. So if I entered 5 in width and 50 in Length, I want the answer displayed automatically in Total. How would I do that.
Appreciate it
PHP Calculator
Moderator: General Moderators
Re: PHP Calculator
it seems to be client slide script. if it is very simple calculation you can perform through javascript.
text box on change function you can perform calculation and print int by automatic.
text box on change function you can perform calculation and print int by automatic.
Re: PHP Calculator
Hi. Can you please post the code you have written so far? Where are you stuck?
-
perfect123
- Forum Newbie
- Posts: 6
- Joined: Wed Jul 15, 2009 12:11 pm
Re: PHP Calculator
I got it to work now, but stuck on another problem which I need urgent help with. Please can you help me.
I have created a search box which potentially works. But I wish to insert the results in to the text box rather than having them on the page
I have a text box and a search button next to it. so When I put in a search and click search, the results should appear in the ref text box. I hope you understand what I mean. Please Help. Here is the code:
I have created a search box which potentially works. But I wish to insert the results in to the text box rather than having them on the page
I have a text box and a search button next to it. so When I put in a search and click search, the results should appear in the ref text box. I hope you understand what I mean. Please Help. Here is the code:
Code: Select all
<form action="test_search.php" method="get">
<input type="text" name="query" id="query" size="40" value="" action="Search.php" columns="2" autocomplete="off" delay="1500">
<input type="submit" value="Search">
<input type="hidden" name="search" value="1">
</form>
<center></center>
</div>
<p> </p>
<?
$myServer = '*****';
$myUser = '****';
$myPass = '*****';
$myDB = '*******';
$SpecRef = $_GET['query'];
print ("$SpecRef");
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//error message (not found message)begins
$XX = "No Matches Found";
//query details table begins
$query = ("SELECT * FROM ******** WHERE Spec_Ref LIKE'$SpecRef%' ");
// $query = ("SELECT * FROM *******");
print(' is what you searched for:');
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Record" . ($numRows == 1 ? "" : "s") . " Found </h1>";
//display the results
echo '<textarea>';
while($row = mssql_fetch_array($result))
{
echo $row["Spec_Ref"] . "\n"; }
echo '</textarea>';
//close the connection
mssql_close($dbhandle);
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["Spec_Ref"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
//textareaContent = "";
//while ($row = @mysql_fetch_array($query))
//{
//$var1=$row["Player"];
//$var2=$row["Avg"];
//$var3=$row["HR"];
//$var4=$row["RBI"];
$textareaContent .= "Spec Ref: $var1 Avg: $var2 HR: $var3 RBI $var4 <br/>";
//}
//if (!isset($var1) || $var1=="") {
//echo $XX;
//}
?>
Last edited by Benjamin on Tue Jul 21, 2009 6:58 am, edited 1 time in total.
Reason: Added [code=php] tags.
Reason: Added [code=php] tags.
- turbolemon
- Forum Commoner
- Posts: 70
- Joined: Tue Jul 14, 2009 6:45 am
- Location: Preston, UK
Re: PHP Calculator
Code: Select all
<form action="test_search.php" method="get">
<input type="text" name="query" id="query" size="40" value="" action="Search.php" columns="2" autocomplete="off" delay="1500">
<input type="submit" value="Search">
<input type="hidden" name="search" value="1">
</form>
<center></center>
</div>
<p> </p>
<?
$myServer = '*****';
$myUser = '****';
$myPass = '*****';
$myDB = '*******';
$SpecRef = $_GET['query'];
print ("$SpecRef");
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//error message (not found message)begins
$XX = "No Matches Found";
//query details table begins
$query = ("SELECT * FROM ******** WHERE Spec_Ref LIKE'$SpecRef%' ");
// $query = ("SELECT * FROM *******");
print(' is what you searched for:');
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Record" . ($numRows == 1 ? "" : "s") . " Found </h1>";
//display the results
echo '<textarea>';
while($row = mssql_fetch_array($result))
{
echo $row["Spec_Ref"] . "\n"; }
echo '</textarea>';
//close the connection
mssql_close($dbhandle);
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["Spec_Ref"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
//textareaContent = "";
//while ($row = @mysql_fetch_array($query))
//{
//$var1=$row["Player"];
//$var2=$row["Avg"];
//$var3=$row["HR"];
//$var4=$row["RBI"];
$textareaContent .= "Spec Ref: $var1 Avg: $var2 HR: $var3 RBI $var4 <br/>";
//}
//if (!isset($var1) || $var1=="") {
//echo $XX;
//}
?>
Code: Select all
...
while ($row = mssql_fetch_array($result,MSSQL_ASSOC))
$tmp[] = $row;
mssql_close($dbhandle);
echo "<textarea>";
foreach ($tmp as $record) {
...