Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Trying to code a dealer locator from VB to Java

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Location
    Inglis, Fl.
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trying to code a dealer locator from VB to Java

    Hello everyone. I am a college student at a community college and just took my first Java class. A local business asked me for help with their website. They have a dealer locator aspect of their website that was written for them in VB but now no longer works and never worked for browsers other than IE. They want this page re-written into Java or JavaScript and working properly. I have all the website files (CSS and spread sheets for the zip codes and dealer info), but I am afraid I am in way over my head. I tried to convert all to JavaScript with the intention to correct inconsistencies...but that did not work. Below I will paste the VB and below that I will paste my attempt. If anyone can help, I would greatly appreciate it.

    <%
    	dim ZipCode
    	dim GetDealersByZipCode
     
    	ZipCode = Request.QueryString("ZipCode")
     
    	if ZipCode <> "" then
    		GetDealersByZipCode = true
    	else
    		GetDealersByZipCode = false
    	end if
     
    	if GetDealersByZipCode then
    		dim DealerIDs
    		dim sql
     
    		'Get the list of dealer that link to the zip code enterd
    		Set connzips = Server.CreateObject("ADODB.Connection")
    		set rs = Server.CreateObject("ADODB.RecordSet")
    		connzips.open Application("ProLineZIPSUPDConnectionString")
     
    		sql = "select top 50 * from zipsupd where [ZIP_CODE] = '" & replace(ZipCode,"'","''") & "'"
    		rs.Open sql, connzips
     
    		dim counter
    		counter = 0
    		DealerIDs = ""
    		do while not rs.eof
    			if counter = 0 then
    				DealerIds = DealerIds & rs(1).value
    			else
    				DealerIds = DealerIds & "," & rs(1).value
    			end if
     
    			rs.movenext
    			counter = counter + 1
    		loop
     
    		rs.close
    		connzips.close
    		set connzips = nothing
     
     
     
    	end if
    %>
     
    <script language="javascript">
    	function Submit_ZipCodeFinder(){
    		location.href = "_Dealer_Locator.asp?ZipCode=" + document.getElementById("txtZipCode").value
    	}
    </script>
    <link href="Pro-Line2011_New.css" rel="stylesheet" type="text/css">
    <body class="Black_10">
    <Table style="font-family:arial;font-size:12px;">
    	<tr>
    		<td colspan=2>
    		<%
    			if ZipCode then
    				response.write("<br><span style='color:green;'>Results are listed below.</span>")
    			end if
    		%>
    		</td>
    	</tr>
    	<tr>
    		<td>Enter Zip Code Here:</td>
    		<td>
    			<input type=text size=5 maxlength=5 name=txtZipCode id=txtZipCode/>
     
    		</td>
    	</tr>
    	<tr>
    		<td colspan=2 align="right">
    			<input type="Button" onclick="Submit_ZipCodeFinder();" value="Locate Dealer" name="Find Dealer" id="Find Dealer"/>
     
    		</td>
    		<% if GetDealersByZipCode = false then %>
     
    <%
    	else 'Show the zip code results
    		if DealerIDs <> "" then 'There are results
    %>
    	</tr>
    </table>
     
    <hr>
    <table style="font-family:arial;font-size:12px;">
    	<tr>
    		<th align="left" style="text-decoration:underline;">Results</th>
    	</tr>
    <%
    			Set conndl = Server.CreateObject("ADODB.Connection")
    			conndl.open Application("prolinedlConnectionString")
     
    			sql = "select * from [Sheet1$] where account in (" & DealerIds & ")"
     
    			rs.open sql, conndl
     
    			counter = 0
    			do while not rs.eof
    				if counter mod 2 = 1 then
    					bgcolor = "#ffffff"
    				else
    					bgcolor = "#efefef"
    				end if
     
    				strMap = "<a href='http://www.mapquest.com/maps/map.adp?formtype=address&address=" & _
    					rs("Address_1").value & "&city=" & rs("City").value & "&state=" & rs("State").value & _
    					"&zipcode=" & rs("Zip").value & "&country=US' style='font-size:11px;' target=_blank>" & _
    					"(map)</a>"
     
    				strDisplay = "<b>" & rs("Name").value & "</b> " & strMap & _
    					"<br/><div style='padding-left:10px;'>" & _
    					rs("Address_1").value  & "<br/>"
     
    				if rs("Address_2").value <> "" then
    					strDisplay = strDisplay & rs("Address_2").value & "<br/>"
    				end if
     
    				strDisplay = strDisplay & rs("City").value & ", " & rs("state").value & " " & rs("Zip").value & "<br/>"
     
    				if rs("Phone").value <> "" then
    					strDisplay = strDisplay & "Phone: " & rs("Phone").value & "<br/>"
    				end if
     
    				if rs("Fax").value <> "" then
    					strDisplay = strDisplay & "Fax: " & rs("fax").value & "<br/>"
    				end if
     
    				if rs("Web").value <> "" then
    					strDisplay = strDisplay & "<a target=_blank href='http://" & rs("Web").value & "'>" & rs("Web").value & "</a>"
    				end if
     
    				strDisplay = strDisplay & "</div>"
    %>
    	<tr>
    		<td style='padding: 4 4 4 4;background-color:<%=bgcolor%>;'>
    			<%=strDisplay%>
    		</td>
    	</tr>
    <%
    				counter = counter + 1
    				rs.movenext
    			loop
    			conndl.close
    			set conndl = nothing
    		else
    %>
    	<hr>
    	<span style="color:Red;font-family:arial;font-size:12px;">No Results</span>
    <%
    		end if
     
     
     
    	end if
    %>
    </table>
    <%
    	'Deallocate all
    	set rs = nothing
    %>

    My corrections
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Pro-Line Boats - Dealer Locator</title>
    <style type="text/css">
    <!--
    body {
    	background-color: #334A67;
    	background-image: url(Images/Background_Gradient.jpg);
    }
    -->
    </style>
    <link href="Pro-Line2011_New.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    <!--
    a:link {
    	color: #334A67;
    }
    a:visited {
    	color: #CCCCCC;
    }
    -->
    </style>
     
    <script src="AC_RunActiveContent.js" language="javascript"></script>
     
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
     
     
    </head>
     
     
    <body>
    <!-- DO NOT MOVE! The following AllWebMenus linking code section must always be placed right AFTER the BODY tag-->
    <!-- ******** BEGIN ALLWEBMENUS CODE FOR menu ******** -->
    <script type="text/javascript">var MenuLinkedBy="AllWebMenus [4]",awmMenuName="menu",awmBN="834";awmAltUrl="";</script><script charset="UTF-8" src="menu.js" type="text/javascript"></script><script type="text/javascript">awmBuildMenu();</script>
    <!-- ******** END ALLWEBMENUS CODE FOR menu ******** -->
     
    <table width="1010" align="center" cellpadding="0" cellspacing="0">
      <tr valign="middle">
        <td colspan="2">      <div align="right">
            <table width="1023" align="center" cellpadding="5" cellspacing="5">
              <tr>
                <td width="404">
                  <div align="left"><img src="Images/2011Pro-LineBoats_Logo7.png" width="375" height="55"></div>
                </td>
                <td width="536" align="left"><table width="443" align="left" cellpadding="5" cellspacing="5">
                  <tr>
                    <td width="391" valign="top">
                      <a id="awmAnchormenu" name="awmAnchormenu"></a></td>
                  </tr>
                </table></td>
              </tr>
            </table>
        </div></td>
        <td width="84">&nbsp;</td>
      </tr>
      <tr>
        <td width="4">&nbsp;</td>
        <td width="1012"><table width="1000" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
            <td><img src="Images/Main/DealerLocator.jpg" alt="" width="1010" height="476"></td>
          </tr>
          <tr align="center">
            <td bgcolor="#FFFFFF"><div align="left">
              <table width="1005" cellspacing="0" cellpadding="0">
                <tr>
                  <td>              
                </tr>
                <tr>
                  <td><table width="961" cellspacing="5" cellpadding="5">
                    <tr>
                      <td width="939"><span class="HeadingMedium">If you are in the US or Puerto Rico, all you need to do is enter your zip code
    				  and we&rsquo;ll let you know who your nearest dealer is. <br>
    				  <br>And, as always, if you experience any problems finding your Pro-Line dealer please do not hesitate to call us at (800) 344-1281.
    				  <br><br>PS. Your new boat is waiting for you. Hurry up and find a dealer near you!</span></td>
                    </tr>
                  </table>                </td>
                </tr>
                <tr>
                  <td>
                    <table width="895" align="center" cellpadding="2" cellspacing="2">
                      <tr valign="top">
                        <td colspan="2" class="Black_10">
    <script language="javascript" type="text/JavaScript">
    	Object ZipCode = null;
    	Object GetDealersByZipCode = null;
     
    	ZipCode = Request.QueryString("ZipCode");
     
    	if ( ! ZipCode.equals(""))
    	{
    		GetDealersByZipCode = true;
    	}
    	else
    	{
    		GetDealersByZipCode = false;
    	}
     
    	if (GetDealersByZipCode)
    	{
    		Object DealerIDs = null;
    		Object sql = null;
     
    		//Get the list of dealer that link to the zip code enterd
    //VB TO JAVA CONVERTER WARNING: VB to Java Converter converts from VB(.NET), not VB6.
    		Set connzips = Server.CreateObject("ADODB.Connection");
    		set rs = Server.CreateObject("ADODB.RecordSet");
    		connzips.open Application("ProLineZIPSUPDConnectionString");
     
    		sql = "select top 50 * from zipsupd where [ZIP_CODE] = '" + ZipCode.toString().replace("'", "''") + "'";
    		rs.Open sql, connzips;
     
    		Object counter = null;
    		counter = 0;
    		DealerIDs = "";
    		while (! rs.eof)
    		{
    			if (counter == 0)
    			{
    				DealerIDs = DealerIDs + rs(1).value;
    			}
    			else
    			{
    				DealerIDs = DealerIDs.toString() + "," + rs(1).value;
    			}
     
    			rs.movenext;
    			counter = counter + 1;
    		}
     
    		rs.close;
    		connzips.close;
    		set connzips = null;
     
     
     
    	}
     
     
    	function Submit_ZipCodeFinder(){
    		location.href = "DealerLocator.asp?ZipCode=" + document.getElementById("txtZipCode").value
    	}
    </script>
    <link href="Pro-Line2009.css" rel="stylesheet" type="text/css">
    <body class="DarkGray12">
    <Table style="font-family:arial;font-size:12px;">
    	<tr>
    		<td colspan=2>
    <script language="javascript" type="text/JavaScript">
    			if (ZipCode)
    			{
    				response.write("<br><span style='color:green;'>Results are listed below.</span>");
    			}
    </script>
    		</td>
    	</tr>
    	<tr>
    		<td>Enter Zip Code Here:</td>
    		<td>
    			<input type=text size=5 maxlength=5 name=txtZipCode id=txtZipCode/>
     
    		</td>
    	</tr>
    	<tr>
    		<td colspan=2 align="right">
    			<input type="Button" onclick="Submit_ZipCodeFinder();" value="Locate Dealer"/>
     
    		</td>
    <script language="javascript" type="text/JavaScript">
    		if GetDealersByZipCode == false then
     
     
    	else //Show the zip code results
    	{
    		if ( ! DealerIDs.equals("")) //There are results
    		}
    </script>
    	</tr>
    </table>
     
    <hr>
    <table style="font-family:arial;font-size:12px;">
    	<tr>
    		<th align="left" style="text-decoration:underline;">Results</th>
    	</tr>
    <script language="javascript" type="text/JavaScript">
    //VB TO JAVA CONVERTER WARNING: VB to Java Converter converts from VB(.NET), not VB6.
    			Set conndl = Server.CreateObject("ADODB.Connection");
    			conndl.open Application("prolinedlConnectionString");
     
    			sql = "select * from [Sheet1$] where account in (" + DealerIds + ")";
     
    			rs.open sql, conndl;
     
    			counter = 0;
    			while (! rs.eof)
    			{
    				if (counter % 2 == 1)
    				{
    					bgcolor = "#ffffff";
    				}
    				else
    				{
    					bgcolor = "#efefef";
    				}
     
    				strMap = "<a href='http://www.mapquest.com/maps/map.adp?formtype=address&address=" + rs("Address_1").value + "&city=" + rs("City").value + "&state=" + rs("State").value + "&zipcode=" + rs("Zip").value + "&country=US' style='font-size:11px;' target=_blank>" + "(map)</a>";
     
    				strDisplay = "<b>" + rs("Name").value + "</b> " + strMap + "<br/><div style='padding-left:10px;'>" + rs("Address_1").value + "<br/>";
     
    				if ( ! rs("Address_2").value.equals(""))
    				{
    					strDisplay = strDisplay + rs("Address_2").value + "<br/>";
    				}
     
    				strDisplay = strDisplay + rs("City").value + ", " + rs("state").value + " " + rs("Zip").value + "<br/>";
     
    				if ( ! rs("Phone").value.equals(""))
    				{
    					strDisplay = strDisplay + "Phone: " + rs("Phone").value + "<br/>";
    				}
     
    				if ( ! rs("Fax").value.equals(""))
    				{
    					strDisplay = strDisplay + "Fax: " + rs("fax").value + "<br/>";
    				}
     
    				if ( ! rs("Web").value.equals(""))
    				{
    					strDisplay = strDisplay + "<a target=_blank href='http://" + rs("Web").value + "'>" + rs("Web").value + "</a>";
    				}
     
    				strDisplay = strDisplay + "</div>";
    </script>
     
    	<tr>
    		<td style='padding: 4 4 4 4;background-color:=bgcolor;'>
     
     
    	</td>
    	</tr>
    <script language="javascript" type="text/JavaScript">
    		counter = counter + 1;
    				rs.movenext;
    			}
    			conndl.close;
    			set conndl = null;
    		}
    		else
    		{
    	<hr>
    	<span style="color:Red;font-family:arial;font-size:12px;">No Results</span>
    }
    </script>
    </table>
    <script language="javascript" type="text/JavaScript">
    //Deallocate all
    	set rs = null;
    </script>
     
    	</td>
                        </tr>
                    </table></td>
                </tr>
              </table>
            </div></td>
          </tr>
          <tr align="center">
            <td bgcolor="#FFFFFF">&nbsp;          </td>
          </tr>
          <tr>
            <td bgcolor="#FFFFFF"><div align="center"></div></td>
          </tr>
        </table></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td class="Specs"><div align="left"><span class="White_9">Copyright &copy; 2010 Pro-Line Boats. All Rights Reserved.</span><br>
        </div></td>
        <td>&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Trying to code a dealer locator from VB to Java

    java != javascript Not sure exactly what you have and what you need, but it seems the original code is server side, so to port it you will probably need some sort of server side alternative (javascript is client side). What to choose is dependent upon the capabilities of the server (php, java, perl, etc...)

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Location
    Inglis, Fl.
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Trying to code a dealer locator from VB to Java

    Well, that certainly helps point me in the right direction. How do I find out the capabilities of the server?

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Trying to code a dealer locator from VB to Java

    Contact the service provider and ask.

Similar Threads

  1. Need java code help
    By Gradybaby16 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 19th, 2010, 10:54 AM
  2. Replies: 2
    Last Post: August 1st, 2010, 06:29 AM
  3. Help With Java Game Code
    By CheekySpoon in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 26th, 2010, 04:07 PM
  4. Convert C/C++ code to Java
    By cristianll in forum What's Wrong With My Code?
    Replies: 13
    Last Post: November 14th, 2009, 02:43 AM
  5. Convert Java Program to Java ME code
    By rinchan11 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: October 5th, 2009, 10:18 PM