IanNav
Programmer
- Feb 26, 2001
- 79
Hi,
I have a bit of an Odd one... And i think its quite hard to explain.
I'll try and explain anyway.
I am trying to write a simple order entry system.
On my main order entry screen i have the following input fields
- Media Code
- Customer ID
- Customer Payer ID (which can be different)
- Order Source (ie Telephone, Web, Mail-order, Fax)
For each of these i would like a "check" or "validate" hyperlink next to the text box (or submit button, but i want to limit the amount of nested submits for simplicity).
When the user click the "check" link, i would ideally like it to call a PHP function that checks the value is valid. (I’ve written the functions, see below a example one for the customer ID)
check_customer($custid)
{
include ("../includes/connect_db.php");
$sqlstr = "SELECT * FROM customer WHERE id='$custid'";
$result = mysql_query($sqlstr);
$data = mysql_fetch_array($result);
$num = mysql_numrows($result);
mysql_close();
if($num =1)
{
return true;
}
else
{
return false;
}
}
Then based on whether id returns true or false i would like to
true : Change the text box with the value inside to a label (so it is not editable).
false : alert("Customer not Valid), then it blanks the box and set focus again.
The main problem i am having is passing what is in the textbox with using the submit button and passing it to my function for evaluation.
I also then need help in changing the pages appearance based on the true or false returned.
I realise i haven't explained this very well - apologies.
Any help would be appreciated.
Since i have 3 or 4 things to check on this 1 page as well as the submit to continue to the next step i think nesting multiple submits would be too messy. There must be an easier way!
Cheers
Ian
I have a bit of an Odd one... And i think its quite hard to explain.
I'll try and explain anyway.
I am trying to write a simple order entry system.
On my main order entry screen i have the following input fields
- Media Code
- Customer ID
- Customer Payer ID (which can be different)
- Order Source (ie Telephone, Web, Mail-order, Fax)
For each of these i would like a "check" or "validate" hyperlink next to the text box (or submit button, but i want to limit the amount of nested submits for simplicity).
When the user click the "check" link, i would ideally like it to call a PHP function that checks the value is valid. (I’ve written the functions, see below a example one for the customer ID)
check_customer($custid)
{
include ("../includes/connect_db.php");
$sqlstr = "SELECT * FROM customer WHERE id='$custid'";
$result = mysql_query($sqlstr);
$data = mysql_fetch_array($result);
$num = mysql_numrows($result);
mysql_close();
if($num =1)
{
return true;
}
else
{
return false;
}
}
Then based on whether id returns true or false i would like to
true : Change the text box with the value inside to a label (so it is not editable).
false : alert("Customer not Valid), then it blanks the box and set focus again.
The main problem i am having is passing what is in the textbox with using the submit button and passing it to my function for evaluation.
I also then need help in changing the pages appearance based on the true or false returned.
I realise i haven't explained this very well - apologies.
Any help would be appreciated.
Since i have 3 or 4 things to check on this 1 page as well as the submit to continue to the next step i think nesting multiple submits would be too messy. There must be an easier way!
Cheers
Ian