?
Solved

Setting hidden value

Posted on 2006-11-22
4
Medium Priority
?
417 Views
Last Modified: 2008-02-13
It seems like it should work to me, but I am not having much luck with it.  I get the 2 message boxes with the "FullAddress" & "point" but for some reason it is not setting my hidden form value geoAddress = point.  Thanks in advance for the help.

<script type="text/javascript">  
    function showAddress(address) {
    geocoder = new GClientGeocoder();
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              //alert(address + " not found");
            } else {
            alert(point);
            document.Person.geoAddress.value=point;
            }
          }
        );
      }
    }
    </script>

<script>
function validate(){
var FullAddress = document.Person.Address.value + ' ' + document.Person.City.value + ', ' + document.Person.State.value + ' ' +  document.Person.Zip.value;
alert(FullAddress);
showAddress(FullAddress);
}
</script>
0
Comment
Question by:jayh99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:bpmurray
ID: 18000252
What's document.Person? It looks quite odd. Can you post a little of the markup so we can see exactly what it is you're trying to access, i.e. something of the actual HTML.
0
 
LVL 15

Accepted Solution

by:
bpmurray earned 120 total points
ID: 18000261
For example, the following works fine:

<html><head>
<script type="text/javascript">  
function getElement(elem) {
   return document.getElementById ? document.getElementById(elem) : eval("document.all." + elem);
}

function showAddress(address) {
   geocoder = new GClientGeocoder();
   if (geocoder) {
       geocoder.getLatLng(address,
                          function(point) {
                             if (!point) {
                                alert(address + " not found");
                             } else {
                                alert(point);
                                getElement("geoAddress").value=point;
                             }
                          });
   }
}
</script>

<script>
function validate(){
   var FullAddress = getElement("Address").value + ' ' +
      getElement("City").value + ', ' + getElement("State").value + ' ' +
      getElement("Zip").value;
   alert(FullAddress);
   showAddress(FullAddress);
}
</script>

</head><body>
Address: <input id="Address" /><br />
City: <input id="City" /><br />
State: <input id="State" /><br />
Zip: <input id="Zip" onblur="validate();"/><br />
</body></html>
0
 
LVL 1

Author Comment

by:jayh99
ID: 18003755
Person is my form's name.  You are completing the person's identification on the page.  I'll post the code when I get a chance to pull the page off my other computer.
0
 
LVL 1

Author Comment

by:jayh99
ID: 18003786
<!--#Include File="dbConn.asp"-->
<%
If Session("Username") = "" Then
Response.Redirect "Login_Form.asp"
End If

If Not Request("DLNo") = "" Then
DLNo = Replace(Request("DLNo"),"-","")

strSQL = "SELECT * FROM Buyer WHERE DL = '" & DLNo & "' ORDER BY strTimestamp DESC;"

'Open the recordset with the SQL query
rsNewInfo.Open strSQL, adoCon


If not rsNewInfo.EOF = True Then
Name = rsNewInfo.Fields("Name")
Address = rsNewInfo.Fields("Address")
City = rsNewInfo.Fields("City")
State = rsNewInfo.Fields("State")
Zip = rsNewInfo.Fields("Zip")
DOB = rsNewInfo.Fields("DOB")
End If

Else

Response.Redirect("Index.asp?msg=1")


End If

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Axinym Corporation -- Sudafed Tracking...  Take back your community</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Axinym Corporation, Sudafed Purchase Tracking" />
<link rel="stylesheet" href="Sudafed.css" type="text/css" media="screen,projection" />

<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAl-3ZboM2_f9yjZTXTsh1KxRQWaFEKaw_MRNWqEuurOrBPxI3DRSbXFalMHAENayoM90eXcfs7FbwRQ"
      type="text/javascript"></script>


<script type="text/javascript">  
    function showAddress(address) {
    geocoder = new GClientGeocoder();
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              //alert(address + " not found");
            } else {
            document.Person.geoAddress.value=point;
            }
          }
        );
      }
    }
    </script>

<script>
function validate(){
var msg = 'You must complete the following fields:';

var FullAddress = document.Person.Address.value + ' ' + document.Person.City.value + ', ' + document.Person.State.value + ' ' +  document.Person.Zip.value;
showAddress(FullAddress);

//Drivers License Number
if(document.Person.DLNo.value.length == 0){
msg=msg.concat(" \n ID Number");
}
//Name
if(document.Person.Name.value.length == 0){
msg=msg.concat(" \n Name");
}
//Address
if(document.Person.Address.value.length == 0){
msg=msg.concat(" \n Address");
}

//City
if(document.Person.City.value.length == 0){
msg=msg.concat(" \n City");
}
//State
if(document.Person.State.value.length == 0){
msg=msg.concat(" \n State");
}
//Zip
if(document.Person.Zip.value.length == 0){
msg=msg.concat(" \n Zip");
}
//Date of Birth
if(document.Person.DOB.value.length == 0){
msg=msg.concat(" \n Date of Birth");
}
//Quantity
if(document.Person.Quantity.value.length == 0){
msg=msg.concat(" \n Purchase Quantity");
}
//Strength
if(document.Person.Strength.value.length == 0){
msg=msg.concat(" \n Purchase Strength");
}
//Initials
if(document.Person.Initials.value.length == 0){
msg=msg.concat(" \n Seller Initials");
}

if(msg.length > 39) {
alert(msg);
return false;
}


var purchasetotal = document.Person.Strength.value * document.Person.Quantity.value;
if (purchasetotal > 3000) {
alert('Buyer cannot purchase more than 3000 mg at one time! \n \n Amount Requested: ' + purchasetotal + ' mg');
return false;
}


var weeklytotal = parseFloat(purchasetotal) + parseFloat(document.Person.Total.value)
if (parseFloat(purchasetotal) + parseFloat(document.Person.Total.value) > 3000){
alert('This purchase would exceed the 3000 mg per week total for this buyer! \n \n Weekly Total Requested: ' + weeklytotal + ' mg');
return false;
}

}
</script>


</head>

<body onunload="GUnload()">
<div id="container" >

<div id="header">
</div>

<div id="navigation">
<ul>
<li class="selected"><a href="Index.asp">Home</a></li>
<li><a href="ReportMenu.asp">Reporting</a></li>
</ul>
</div>

<div id="content">
<div align="center"><h2><%=Session("PharmacyName")%></h2></div>
       <form name="Person" action="Complete.asp" onSubmit="return validate();">
       <h2>Complete the Buyer's Information:</h2>
       <table width="487" height="254" border="0" background="images/smDL.png">
       <tr>
         <td>
             <br/>
             <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
           <tr>
             <td width="25%"><p>&nbsp;</p>
               <p>&nbsp;</p>
               <p><img src="images/Person.jpg" alt="" hspace="20" /></p>
               </td>
             <td width="75%">
                   <br/><br/><br/>
                   <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td><b>ID #:</b></td>
                 <td><input name="DLNo" id="DLNo" type="text" size="23" class="text" value="<%=Request("DLNo")%>" />
                   xxxx-xx-xxxx</td>
               </tr>
               <tr>
                 <td width="130"><b>Name:</b></td>
                 <td><input name="Name" type="text" size="32" class="text" value="<%=Name%>" /></td>
               </tr>
               <tr>
                 <td width="130"><b>Address:</b></td>
                 <td><input name="Address" type="text" size="37" class="text" value="<%=Address%>" /></td>
               </tr>
               <tr>
                 <td><b>City:</b></td>
                 <td><input name="City" id="City" type="text" size="30" class="text" value="<%=City%>" /></td>
               </tr>
               <tr>
                 <td><b>State:</b> </td>
                 <td><input name="State" id="State" type="text" size="8" class="text" value="<%=State%>" />
                   &nbsp;&nbsp;&nbsp;&nbsp;<b>Zip:</b>
                   <input name="Zip" type="text" size="15" class="text" value="<%=Zip%>" /></td>
               </tr>
               <tr>
                 <td width="130"><b>Date of Birth:</b></td>
                 <td><input name="DOB" type="text" size="15" class="text" value="<%=DOB%>" />
                   xx/xx/xxxx</td>
               </tr>
             </table></td>
           </tr>
         </table>             </td>
       </tr>
     </table>
      &nbsp;&nbsp;&nbsp;<a href="Index.asp" target="_top">Cancel</a>       
       <p>&nbsp;</p>
     <p>    
<div class="box">
<h3>Review Buyer History</h3>
<%
If not rsNewInfo.EOF = True Then
rsNewInfo.MoveFirst
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="2" colspan="4"><img src="images/bar.png" width="100%" height="1"></td>
  </tr>
  <tr>
      <td><b>Purchase Date</b></td>
      <td align="center"><b>Quantity</b></td>
      <td align="center"><b>Strength</b></td>
      <td align="center"><b>Amount</b></td>
</tr>
<%
Do
If datediff("d", rsNewInfo.Fields("strDate"),Now) <= 7 then

weekTotal = weekTotal + clng(replace(rsNewInfo.Fields("Amount"), " mg",""))

If weekTotal > 2900 then
flag = 1
End If

bg = "#FFBBBB"
Else
bg = "#FFFFFF"
End If
%>
<tr bgcolor="<%=bg%>">
      <td><%=rsNewInfo.Fields("strTimestamp")%></td>
      <td align="center"><%=rsNewInfo.Fields("Quantity")%></td>
      <td align="center"><%=rsNewInfo.Fields("Strength")%></td>
      <td align="center"><%=rsNewInfo.Fields("Amount")%></td>
</tr>  
<%
rsNewInfo.MoveNext
Loop Until rsNewInfo.EOF = True

If weekTotal = "" then weekTotal = 0
%>
<tr>
    <td height="2" colspan="4"><img src="images/bar.png" width="100%" height="1"></td>
</tr>

<tr>
      <td colspan="4">
      <%
      If weekTotal < 1500 then
      strColor = "Green"
      End If
      
      If weekTotal > 2000 then
      strColor = "#FF9900"
      End If
      
      If weekTotal > 2999 then
      strColor = "Red"
      End If
      %>
      <b>7 Day Total: <font color="<%=strColor%>"><%=weekTotal%> mg</font></b>
      
      </td>
</tr>
</table>
<%
Else
%>
This buyer has no previous purchases.
<%
End If
%>
</div>
<%
If not flag = 1 Then
%>
<br/>
<h3>Purchase Information</h3>
<table width="450">
      <tr>
      <td>Pack Quantity: <input name="Quantity" type="text" size="15" class="text" value="<%=Request("Quantity")%>" /> tablets</td>
      </tr>
      <tr>
      <td>Strength: <input name="Strength" type="text" size="15" class="text" value="<%=Request("Strength")%>" /> mg
      </td>
      </tr>
      <tr>
      <td>Seller Initials: <input name="Initials" type="text" class="text" value="" size="5" maxlength="3" /></td>
      </tr>
</table>      
       <input type="hidden" name="Search" value="1" />
<br/>
<%
If Request("msg") = 3000 Then
%>
<div align="center">
<span class="important">A buyer is not allowed to purchase more than 3000 mg of Sudafed at a one time.</span>
</div>
<%
End If
%>
<input type="hidden" name="Total" value="<%=weektotal%>" />
<input type="hidden" name="geoAddress" id="geoAddress" value="">
<input type="submit" name="Submit" class="searchbutton" value=" Confirm Purchase "/>      
</p>

<%
Else
%>
<br/>
<span class="important">This buyer has purchased the weekly 3000 mg limit of Sudafed.</span>
<%
End If
%>
<br/>&nbsp;
<br/>&nbsp;
     </form>
</div>





<div id="footer">
<p>&nbsp;</p>
</div>

</div>
</body>
</html>
<%
rsNewInfo.Close
adoCon.Close
%>
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question