Need to modify this code to retrieve from database

Results 1 to 3 of 3

Thread: Need to modify this code to retrieve from database

  1. #1
    Zintle Guest

    Default Need to modify this code to retrieve from database

    Can someone help me modify this code so that, a user can search for a service from a list specified in the service name drop-down list, or search by a business name by typing out themseleves in a textbox. Then i&#039d like to add this: Sorry no records matched your query, please refine it.<BR><BR>Here is the code below. Bill helped me with it, but The business name search doesnot work.<BR><BR>FORM Name="whatever" Action="nextPage.asp" Method="Post"<BR>onSubmit="return checkInput(this);"&#062;<BR>...<BR><BR>&#060;SCRIP T Language=JavaScript&#062;<BR>function checkInput( frm )<BR>{<BR> v1 = frm.Service.value;<BR> v2 = frm.BuzName.value;<BR> if ( v1 != "" && v2 != "" )<BR> {<BR> alert("You can give a value for EITHER Service or Business Name but not both.");<BR> return false;<BR> }<BR> if ( v1 == "" && v2 == "" )<BR> {<BR> alert("You must provide a value for either Service or Business Name");<BR> return false;<BR> }<BR> return true;<BR>}<BR>&#060;/SCRIPT&#062;<BR><BR><BR>Then just one SUBMIT button and, on the next page:<BR><BR>&#060;%<BR>&#039 fix up the form field! get rid of extra spaces, change &#039 to &#039&#039 !!<BR>BuzName = Replace( Trim( Request.Form("BuzName") ), "&#039", "&#039&#039" )<BR><BR>If Len( BuzName ) = 0 Then<BR> sql= "SELECT Business.BusName, Business.Industry, Business.[E-mail], Business.[Tel Code], " _<BR> & "Business.[Tel No], Business.Fax, Business.City, [Bus-Serv].ServiceId" _<BR> & " FROM Business INNER JOIN [Bus-Serv] ON Business.BusID = [Bus-Serv].BusID" _<BR> & " WHERE [Bus-Serv].ServiceId Like &#039%" & Request.form("Service") & "%&#039 "<BR><BR>Else<BR><BR> Service = Replace( Trim( Request.Form("Service") ), "&#039", "&#039&#039" )<BR> sql = "SELECT BusName, Industry, [E-mail], [Tel Code], [Tel No], Fax, City" _<BR> & " FROM Business where BusName Like &#039%" & Request.form("BuzName") & "%&#039 "<BR><BR>End If<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Need to modify this code to retrieve from data

    There is nothing obviously wrong from that. Except that *normally* you can&#039t get the value of a drop down list in JS code that way. Which makes me suspicious of other things.<BR><BR>How about emailing *BOTH PAGES* as attachments (please no zip files)? Send them to:<BR><BR>

  3. #3
    Zinhle Guest

    Default RE: Need to modify this code to retrieve from data

    Thank you bill, you will get my e-mail in about 3 hours time, at the moment the network is down at the LAN where I did those pages. It will probably be working in the next 3 hours. you don&#039t know how much you will be saving me by helping me with this one, I&#039m a real web novice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts