Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

real-time input checking

Status
Not open for further replies.

bataraguru

Programmer
Jun 4, 2002
37
MY
hi..
i'm doing my company inventory system.
i want to do one thing that i dont know how to do it..
let say in an add item page i have a form.
in that form have several input text box and one of them
is name 'Serial_CPU'. i want the system to check in the database if the 'Serial_CPU' entered by user exist or not in the database. i dont want to check the 'Serial_CPU' after the main form button (submit) pressed. i just want to check one particular input text box.

the step.
1. enter serial cpu
2. press button/link (beside the input text box) to check if the data exist or not.
3. pop-up new window that can show the serial is exist or not..
4. if serial exist, close pop-up window and entered new serial, if not exist just close the pop-up window and continue enter the remaining input text box.

plese help, im stuck here...

thanks..
 
Hi mate,

What part are you having the problem with?

Have the extra button within your form, check for the value of this button when the form is submitted.

If the value is present, do a query on the DB -

WHERE 'Serial_CPU' = '#form.Serial_CPU#'

Then check to see if any records are returned, if so then it exists in the DB.

If the value of the button is the final submit button, do your normal processing.

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
hi,
this is my prototype form..
test.gif

i have 4 buttons SUBMIT, RESET, BACK & CHECK.
the part that im needing assistance is the CHECK button.
when user entered a Serial_CPU, he/she can check first weather the serial exist in the database or not before submiting the whole form. i have try several way, but failed.

thanks...
 
i think the problem here is the design

if those four buttons are part of the same form, some users will be confused (i know i would be)

if you want them to check the serial number before filling out the rest of the form, then make it a two step process


rudy
 
As Rudy said... it's really a design call. I'd probably be confused by it, too. There are many examples of forms that do this, though. Doesn't make it right, but there is a precedent.

There are two ways you could get the check button to work.

First, the check button could use javascript to check the serial number. In the OnClick event, open a pop-up window to which you've passed the value of the field. Have the pop-up window display a nice little message like "checking for your serial number...", and run a CFQUERY. If it finds it, display some message about "your serial number already exists", and maybe set a hidden flag to prevent the form from being submitted. If it doesn't find it, simply close the window.

Second, you could use server-side processing. Assuming your check button is defined as something like:
Code:
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Check&quot;>
then form would always submit to itself. And you would do something like:
Code:
<CFIF IsDefined(&quot;FORM.submit&quot;)>
  <CFSWITCH expression=&quot;#LCase(FORM.submit)#&quot;>
  <CFCASE value=&quot;check&quot;>
     <!--- the user clicked the check button, run the check process --->
            :
     <!--- output appropriate message based on results --->
  </CFCASE>
  <CFCASE value=&quot;submit&quot;>
      <!--- the user clicked &quot;submit&quot;, process the submition --->
            :
     <!--- and prevent the form from being displayed again --->
     <CFABORT>
  </CFCASE>
       :
     <!--- include as many cases as needed --->
       :
  </CFSWITCH>
</CFIF>


<CFOUTPUT><form action=&quot;#GetFileFromPath(GetBaseTemplatePath())#&quot; method=&quot;POST&quot; ...></CFOUTPUT>

           :
</form>


-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top