Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. I am still struggling to find a fix for this. Can some guru please help?

I am still struggling to find a fix for this. Can some guru please help?

Scheduled Pinned Locked Moved ASP.NET
helpjavascriptcomtoolsjson
21 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samflex
    wrote on last edited by
    #1

    This line of code:

    displays the total miles when calculated between two locations using the javascript code below:

    <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j\_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>
    <script type="text/javascript">
    
    var geocoder, location1, location2;
    
    function initialize() {
        geocoder = new GClientGeocoder();
    }
    
    function showLocation() {
        geocoder.getLocations(document.forms\[0\].address1.value, function (response) {
            if (!response || response.Status.code != 200)
            {
                alert("Sorry, we were unable to geocode the first address");
            }
            else
            {
                location1 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                geocoder.getLocations(document.forms\[0\].address2.value, function (response) {
                    if (!response || response.Status.code != 200)
                    {
                        alert("Sorry, we were unable to geocode the second address");
                    }
                    else
                    {
                        location2 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                        calculateDistance();
                    }
                });
            }
        });
    }
    
    function calculateDistance()
    {
        try
        {
            var glatlng1 = new GLatLng(location1.lat, location1.lon);
            var glatlng2 = new GLatLng(location2.lat, location2.lon);
            var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
    
            document.getElementById('results').innerHTML = '**Address 1:** ' + location1.address + '  
    

    Address 2: ' + location2.address + '
    Distance: ' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';
    }
    catch (error)
    {
    alert(error);
    }
    }

    </script>
    

    </head>

    <body onloa

    Z O J 3 Replies Last reply
    0
    • S samflex

      This line of code:

      displays the total miles when calculated between two locations using the javascript code below:

      <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j\_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>
      <script type="text/javascript">
      
      var geocoder, location1, location2;
      
      function initialize() {
          geocoder = new GClientGeocoder();
      }
      
      function showLocation() {
          geocoder.getLocations(document.forms\[0\].address1.value, function (response) {
              if (!response || response.Status.code != 200)
              {
                  alert("Sorry, we were unable to geocode the first address");
              }
              else
              {
                  location1 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                  geocoder.getLocations(document.forms\[0\].address2.value, function (response) {
                      if (!response || response.Status.code != 200)
                      {
                          alert("Sorry, we were unable to geocode the second address");
                      }
                      else
                      {
                          location2 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                          calculateDistance();
                      }
                  });
              }
          });
      }
      
      function calculateDistance()
      {
          try
          {
              var glatlng1 = new GLatLng(location1.lat, location1.lon);
              var glatlng2 = new GLatLng(location2.lat, location2.lon);
              var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
      
              document.getElementById('results').innerHTML = '**Address 1:** ' + location1.address + '  
      

      Address 2: ' + location2.address + '
      Distance: ' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';
      }
      catch (error)
      {
      alert(error);
      }
      }

      </script>
      

      </head>

      <body onloa

      Z Offline
      Z Offline
      ZurdoDev
      wrote on last edited by
      #2

      You can use an asp:Label and set it's value server side.

      There are only 10 types of people in the world, those who understand binary and those who don't.

      S 1 Reply Last reply
      0
      • Z ZurdoDev

        You can use an asp:Label and set it's value server side.

        There are only 10 types of people in the world, those who understand binary and those who don't.

        S Offline
        S Offline
        samflex
        wrote on last edited by
        #3

        I tried that already and it didn't work.

        Z 1 Reply Last reply
        0
        • S samflex

          This line of code:

          displays the total miles when calculated between two locations using the javascript code below:

          <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j\_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>
          <script type="text/javascript">
          
          var geocoder, location1, location2;
          
          function initialize() {
              geocoder = new GClientGeocoder();
          }
          
          function showLocation() {
              geocoder.getLocations(document.forms\[0\].address1.value, function (response) {
                  if (!response || response.Status.code != 200)
                  {
                      alert("Sorry, we were unable to geocode the first address");
                  }
                  else
                  {
                      location1 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                      geocoder.getLocations(document.forms\[0\].address2.value, function (response) {
                          if (!response || response.Status.code != 200)
                          {
                              alert("Sorry, we were unable to geocode the second address");
                          }
                          else
                          {
                              location2 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                              calculateDistance();
                          }
                      });
                  }
              });
          }
          
          function calculateDistance()
          {
              try
              {
                  var glatlng1 = new GLatLng(location1.lat, location1.lon);
                  var glatlng2 = new GLatLng(location2.lat, location2.lon);
                  var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
          
                  document.getElementById('results').innerHTML = '**Address 1:** ' + location1.address + '  
          

          Address 2: ' + location2.address + '
          Distance: ' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';
          }
          catch (error)
          {
          alert(error);
          }
          }

          </script>
          

          </head>

          <body onloa

          O Offline
          O Offline
          onelopez
          wrote on last edited by
          #4

          I understand what you are trying to do, but not really sure what you are asking... javascript code runs on the client side, the values set on #results are added after the client has loaded the javascript and calculated the distance. Are you attempting to send this data back to the server? you can always use a hidden input

          <input type="hidden" value="something" name="result" />

          or:

          <asp:HiddenField runat="server" ID="result" />

          which can then be ran on postback and checked for a value.

          1 Reply Last reply
          0
          • S samflex

            This line of code:

            displays the total miles when calculated between two locations using the javascript code below:

            <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j\_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>
            <script type="text/javascript">
            
            var geocoder, location1, location2;
            
            function initialize() {
                geocoder = new GClientGeocoder();
            }
            
            function showLocation() {
                geocoder.getLocations(document.forms\[0\].address1.value, function (response) {
                    if (!response || response.Status.code != 200)
                    {
                        alert("Sorry, we were unable to geocode the first address");
                    }
                    else
                    {
                        location1 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                        geocoder.getLocations(document.forms\[0\].address2.value, function (response) {
                            if (!response || response.Status.code != 200)
                            {
                                alert("Sorry, we were unable to geocode the second address");
                            }
                            else
                            {
                                location2 = {lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address};
                                calculateDistance();
                            }
                        });
                    }
                });
            }
            
            function calculateDistance()
            {
                try
                {
                    var glatlng1 = new GLatLng(location1.lat, location1.lon);
                    var glatlng2 = new GLatLng(location2.lat, location2.lon);
                    var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
            
                    document.getElementById('results').innerHTML = '**Address 1:** ' + location1.address + '  
            

            Address 2: ' + location2.address + '
            Distance: ' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';
            }
            catch (error)
            {
            alert(error);
            }
            }

            </script>
            

            </head>

            <body onloa

            J Offline
            J Offline
            jkirkerx
            wrote on last edited by
            #5

            You have to put that in a hidden textbox. The asp.net server remembers everything it generates, and sends back to the browser. So take a dropdownbox for instance, if you populate a dropdown box, and then use javascript to clear it, the server will think that someone tampered with the value, and generate an error. But with a textbox, the server expects the values to change, so that's OK. Only HTML Elements with the word input really post back to the server. All others don't, it's a waste of time and bandwidth.

            button
            checkbox
            color
            date
            datetime
            datetime-local
            email
            file
            hidden
            image
            month
            number
            password
            radio
            range
            reset
            search
            submit
            tel
            text
            time
            url
            week

            So a textbox and a dropdown box use the input element, which is programmable to act like a textbox, dropdownlist, radio button, checkbox and so forth. Make a asp.net textbox object, and set the CSS display: none style="display: none;" Were using the CSS style because I'm skeptical of the visible attribute. Let the textbox show until you prove it works, then use the display. Were using clientIDmode, because the id value will stay the same for use in javascript. Off the top of my head; clientIDmode="static" style=display: none;"> If you don't make the asp.net object, the textbox will most likely give you trouble posting back it's value. [edit]

            document.getElementById('txt_geolocation').value('stuff you geolocation info in here');

            textbox use the attr value, and has no innerHTML.

            S 1 Reply Last reply
            0
            • S samflex

              I tried that already and it didn't work.

              Z Offline
              Z Offline
              ZurdoDev
              wrote on last edited by
              #6

              What didn't work? And what are you trying to do then?

              There are only 10 types of people in the world, those who understand binary and those who don't.

              1 Reply Last reply
              0
              • J jkirkerx

                You have to put that in a hidden textbox. The asp.net server remembers everything it generates, and sends back to the browser. So take a dropdownbox for instance, if you populate a dropdown box, and then use javascript to clear it, the server will think that someone tampered with the value, and generate an error. But with a textbox, the server expects the values to change, so that's OK. Only HTML Elements with the word input really post back to the server. All others don't, it's a waste of time and bandwidth.

                button
                checkbox
                color
                date
                datetime
                datetime-local
                email
                file
                hidden
                image
                month
                number
                password
                radio
                range
                reset
                search
                submit
                tel
                text
                time
                url
                week

                So a textbox and a dropdown box use the input element, which is programmable to act like a textbox, dropdownlist, radio button, checkbox and so forth. Make a asp.net textbox object, and set the CSS display: none style="display: none;" Were using the CSS style because I'm skeptical of the visible attribute. Let the textbox show until you prove it works, then use the display. Were using clientIDmode, because the id value will stay the same for use in javascript. Off the top of my head; clientIDmode="static" style=display: none;"> If you don't make the asp.net object, the textbox will most likely give you trouble posting back it's value. [edit]

                document.getElementById('txt_geolocation').value('stuff you geolocation info in here');

                textbox use the attr value, and has no innerHTML.

                S Offline
                S Offline
                samflex
                wrote on last edited by
                #7

                Thank you guys, all of you for your kindness with your responses. Ryan, I should have been more much clearer. When I said it doesn't work, I meant that yes, it will display results in labels but I could not pass the value of the results to codebehind. Second, I can't pass that value from one multiview to another. Here are some examples:

                //HTML
                <%-- --%>

                     Please verify your order:      10% discount applied
                

                Estimated Total Miles:

                </form>

                //codebehind
                Dim Hiddenresult As HiddenField = form1.FindControl("result")
                lblMiles.Text = Hiddenresult.Value

                As you can see from the sample codes, I am trying to get the value of Hidden field called results and pass that value to preview multiview page called vwPreview but it always comes up blank.

                What am I doing wrong?

                J 1 Reply Last reply
                0
                • S samflex

                  Thank you guys, all of you for your kindness with your responses. Ryan, I should have been more much clearer. When I said it doesn't work, I meant that yes, it will display results in labels but I could not pass the value of the results to codebehind. Second, I can't pass that value from one multiview to another. Here are some examples:

                  //HTML
                  <%-- --%>

                       Please verify your order:      10% discount applied
                  

                  Estimated Total Miles:

                  </form>

                  //codebehind
                  Dim Hiddenresult As HiddenField = form1.FindControl("result")
                  lblMiles.Text = Hiddenresult.Value

                  As you can see from the sample codes, I am trying to get the value of Hidden field called results and pass that value to preview multiview page called vwPreview but it always comes up blank.

                  What am I doing wrong?

                  J Offline
                  J Offline
                  jkirkerx
                  wrote on last edited by
                  #8

                  Don't put the hidden textbox inside the multi view control, place it on the page at the bottom. when you make the textbox, get the value "" or string.empty To diagnose, you have to follow the steps. Step 1: Does the data appear in the textbox Use a regular textbox, and keep it visible, so you can see the data appear in it from your Javascript. Confirm that you can write to the textbox. Diagnose: Try using IE11, press F12, click on the bug, 3rd down on left, and it will tell you if you have a script error, preventing the write. Step2: Post the form back to the server. On the Button Click event, look for the textbox value being posted back. Diagnose: If the textbox has data in it, but no data came back to the server, Check your use of

                  Page.IsPostback

                  button_click
                  if page.ispostback then
                  look for the textbox text.
                  end if

                  I don't know what a multiview control is, so no help from me there on that subject. Fix 1 thing at a time in sequence. Oh, I'm jkirkerx, not RyanDev.

                  S 1 Reply Last reply
                  0
                  • J jkirkerx

                    Don't put the hidden textbox inside the multi view control, place it on the page at the bottom. when you make the textbox, get the value "" or string.empty To diagnose, you have to follow the steps. Step 1: Does the data appear in the textbox Use a regular textbox, and keep it visible, so you can see the data appear in it from your Javascript. Confirm that you can write to the textbox. Diagnose: Try using IE11, press F12, click on the bug, 3rd down on left, and it will tell you if you have a script error, preventing the write. Step2: Post the form back to the server. On the Button Click event, look for the textbox value being posted back. Diagnose: If the textbox has data in it, but no data came back to the server, Check your use of

                    Page.IsPostback

                    button_click
                    if page.ispostback then
                    look for the textbox text.
                    end if

                    I don't know what a multiview control is, so no help from me there on that subject. Fix 1 thing at a time in sequence. Oh, I'm jkirkerx, not RyanDev.

                    S Offline
                    S Offline
                    samflex
                    wrote on last edited by
                    #9

                    Sorry jkirkerx, I didn't mean to imply that you are RyanDev. I was trying to reply to all posts at once by mentioning your name and his. In any case, my apologies. Ok I will take your advice by dealing with one issue at a time. Let's start with my js: You referenced txt_geolocation below: document.getElementById('txt_geolocation').value('stuff you geolocation info in here'); Did you mean results? Please see entire js and you will see that my js has it this way: document.getElementById("results").innerHTML =...

                    <script type="text/javascript">

                        var geocoder, location1, location2, gDir;
                    
                        function initialize() {
                            geocoder = new GClientGeocoder();
                            gDir = new GDirections();
                            GEvent.addListener(gDir, "load", function () {
                                var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
                                var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
                    
                                document.getElementById("results").innerHTML = '**From:** ' + location1.address + '  
                    

                    To: ' + location2.address + '
                    Driving Distance: ' + drivingDistanceMiles.toFixed(2) + ' miles ';
                    });
                    }

                        function showLocation() {
                            geocoder.getLocations(document.forms\[0\].address1.value, function (response) {
                                if (!response || response.Status.code != 200) {
                                    alert("Sorry, we were unable to geocode the first address");
                                }
                                else {
                                    location1 = { lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address };
                                    geocoder.getLocations(document.forms\[0\].address2.value, function (response) {
                                        if (!response || response.Status.code != 200) {
                                            alert("Sorry, we were unable to geocode the second address");
                                        }
                                        else {
                                            location2 = { lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address };
                                            gDir.load('from: ' + location1.address + ' to: ' + location2.address);
                                        }
                                    });
                                }
                            });
                        }
                    
                    </script>
                    

                    And please, what do you mean by ).value('s

                    J 1 Reply Last reply
                    0
                    • S samflex

                      Sorry jkirkerx, I didn't mean to imply that you are RyanDev. I was trying to reply to all posts at once by mentioning your name and his. In any case, my apologies. Ok I will take your advice by dealing with one issue at a time. Let's start with my js: You referenced txt_geolocation below: document.getElementById('txt_geolocation').value('stuff you geolocation info in here'); Did you mean results? Please see entire js and you will see that my js has it this way: document.getElementById("results").innerHTML =...

                      <script type="text/javascript">

                          var geocoder, location1, location2, gDir;
                      
                          function initialize() {
                              geocoder = new GClientGeocoder();
                              gDir = new GDirections();
                              GEvent.addListener(gDir, "load", function () {
                                  var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
                                  var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
                      
                                  document.getElementById("results").innerHTML = '**From:** ' + location1.address + '  
                      

                      To: ' + location2.address + '
                      Driving Distance: ' + drivingDistanceMiles.toFixed(2) + ' miles ';
                      });
                      }

                          function showLocation() {
                              geocoder.getLocations(document.forms\[0\].address1.value, function (response) {
                                  if (!response || response.Status.code != 200) {
                                      alert("Sorry, we were unable to geocode the first address");
                                  }
                                  else {
                                      location1 = { lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address };
                                      geocoder.getLocations(document.forms\[0\].address2.value, function (response) {
                                          if (!response || response.Status.code != 200) {
                                              alert("Sorry, we were unable to geocode the second address");
                                          }
                                          else {
                                              location2 = { lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address };
                                              gDir.load('from: ' + location1.address + ' to: ' + location2.address);
                                          }
                                      });
                                  }
                              });
                          }
                      
                      </script>
                      

                      And please, what do you mean by ).value('s

                      J Offline
                      J Offline
                      jkirkerx
                      wrote on last edited by
                      #10

                      You can use any name you like, so we will use "results" Just make sure the textbox ID matches your javascript I used value, because a textbox does not have innerHTML, it has a value This is value

                      This is innerHTML

                      innerHTML

                      Got It

                      S 1 Reply Last reply
                      0
                      • J jkirkerx

                        You can use any name you like, so we will use "results" Just make sure the textbox ID matches your javascript I used value, because a textbox does not have innerHTML, it has a value This is value

                        This is innerHTML

                        innerHTML

                        Got It

                        S Offline
                        S Offline
                        samflex
                        wrote on last edited by
                        #11

                        Thanks again I got the part about textbox. This is the part that I am trying to understand.

                        document.getElementById("results").innerHTML = 'From: ' + location1.address + '
                        To: ' + location2.address + '
                        Driving Distance: ' + drivingDistanceMiles.toFixed(2) + ' miles ';

                        Does this script above remain as is or do I change innerHTML to value like below?

                        document.getElementById("results").value

                        Your advise is great. I am trying to walk my way from the script to markup. Earlier today, I changed to this --> document.getElementById("results").value on the script and then used this: I put the textbox outside the multiew control. I am really not sure what difference that makes. Multiview control is used to pass values from one page to another. It gives the appearance that you are going from page to another. For instance, in my case, I would like users to fill a form on on view, then when they click Next, all the values they entered previously are displayed in another view. This gives them the opportunity to review what information they entered and certify that they are correct. If they are not, the users can return to previous "page" to make addditional changes. If they are correct, then they submit. So, I tried putting the textbox inside one view, nothing happens. The box is blank. I tried putting it outside the view. Still nothing happened. This is really frustrating.

                        J 1 Reply Last reply
                        0
                        • S samflex

                          Thanks again I got the part about textbox. This is the part that I am trying to understand.

                          document.getElementById("results").innerHTML = 'From: ' + location1.address + '
                          To: ' + location2.address + '
                          Driving Distance: ' + drivingDistanceMiles.toFixed(2) + ' miles ';

                          Does this script above remain as is or do I change innerHTML to value like below?

                          document.getElementById("results").value

                          Your advise is great. I am trying to walk my way from the script to markup. Earlier today, I changed to this --> document.getElementById("results").value on the script and then used this: I put the textbox outside the multiew control. I am really not sure what difference that makes. Multiview control is used to pass values from one page to another. It gives the appearance that you are going from page to another. For instance, in my case, I would like users to fill a form on on view, then when they click Next, all the values they entered previously are displayed in another view. This gives them the opportunity to review what information they entered and certify that they are correct. If they are not, the users can return to previous "page" to make addditional changes. If they are correct, then they submit. So, I tried putting the textbox inside one view, nothing happens. The box is blank. I tried putting it outside the view. Still nothing happened. This is really frustrating.

                          J Offline
                          J Offline
                          jkirkerx
                          wrote on last edited by
                          #12

                          Textboxes don't have innerHTML! They have values! Try the sample below, then go back and work on filling in the data.

                          document.getElementById("results").value = 'See, textboxes do have value';

                          S 1 Reply Last reply
                          0
                          • J jkirkerx

                            Textboxes don't have innerHTML! They have values! Try the sample below, then go back and work on filling in the data.

                            document.getElementById("results").value = 'See, textboxes do have value';

                            S Offline
                            S Offline
                            samflex
                            wrote on last edited by
                            #13

                            Hi again, If you look at the sample in my last post, I have that exactly. I posted exact code I am currently using. Here are the snippets again: //JS:

                            document.getElementById("results").Value = drivingDistanceMiles.toFixed(2);

                            //HTML

                            So, why is results not displaying values?

                            J 1 Reply Last reply
                            0
                            • S samflex

                              Hi again, If you look at the sample in my last post, I have that exactly. I posted exact code I am currently using. Here are the snippets again: //JS:

                              document.getElementById("results").Value = drivingDistanceMiles.toFixed(2);

                              //HTML

                              So, why is results not displaying values?

                              J Offline
                              J Offline
                              jkirkerx
                              wrote on last edited by
                              #14

                              Because value has to be in lower case. Javascript is case sensitive. It has to be typed perfect. Use IE11, and press F12, then the 3rd icon down on the left and run the debugger for JavaScript.

                              S 1 Reply Last reply
                              0
                              • J jkirkerx

                                Because value has to be in lower case. Javascript is case sensitive. It has to be typed perfect. Use IE11, and press F12, then the 3rd icon down on the left and run the debugger for JavaScript.

                                S Offline
                                S Offline
                                samflex
                                wrote on last edited by
                                #15

                                OK, I see it after I made the change. All along, it it in lower case; don't know when I made the switch back to upper case. In any case, we are still back to same orignal problem. I would like to grab that value in code behind but this one line of code gets in the way. If I run this code as is:

                                then it dislays the miles but doesn't do anything else. It doesn;t even recognize rest of form fields that need to be validated and upon click the NEXT buttn takes some action. I suppose the return false is the issue? If I remove it, then the value of request doesn't get grabbed on codebehind. Thanks alot for your patience.

                                J 1 Reply Last reply
                                0
                                • S samflex

                                  OK, I see it after I made the change. All along, it it in lower case; don't know when I made the switch back to upper case. In any case, we are still back to same orignal problem. I would like to grab that value in code behind but this one line of code gets in the way. If I run this code as is:

                                  then it dislays the miles but doesn't do anything else. It doesn;t even recognize rest of form fields that need to be validated and upon click the NEXT buttn takes some action. I suppose the return false is the issue? If I remove it, then the value of request doesn't get grabbed on codebehind. Thanks alot for your patience.

                                  J Offline
                                  J Offline
                                  jkirkerx
                                  wrote on last edited by
                                  #16

                                  Your Javascript, off the top of my head, this is concept code [EDIT] Fixed the error

                                  function showLocation() {

                                  var vFlag = true; // I prefer to presume true, prove me wrong
                                  var parameters = '3.14'; // Build your string
                                  document.getElementByID('results').value = parameters; // set the textbox
                                  var results = document.getElementByID('results').value; // check the length of data in the txt
                                  if (results.length === 0) { // No text, it fails - === is proper, not == or =
                                  vFlag = false; // return failure
                                  alert('my code failed');
                                  }

                                  alert('txt=' + results);

                                  return vFlag;
                                  }

                                  Then on the button off the top of my head. The code is untested, just freewriting here, but it's a concept to prove.

                                  S 1 Reply Last reply
                                  0
                                  • J jkirkerx

                                    Your Javascript, off the top of my head, this is concept code [EDIT] Fixed the error

                                    function showLocation() {

                                    var vFlag = true; // I prefer to presume true, prove me wrong
                                    var parameters = '3.14'; // Build your string
                                    document.getElementByID('results').value = parameters; // set the textbox
                                    var results = document.getElementByID('results').value; // check the length of data in the txt
                                    if (results.length === 0) { // No text, it fails - === is proper, not == or =
                                    vFlag = false; // return failure
                                    alert('my code failed');
                                    }

                                    alert('txt=' + results);

                                    return vFlag;
                                    }

                                    Then on the button off the top of my head. The code is untested, just freewriting here, but it's a concept to prove.

                                    S Offline
                                    S Offline
                                    samflex
                                    wrote on last edited by
                                    #17

                                    Thanks a lot for all your help, jkirkerx. I am beginning to think this is not even possible. I have looked at several examples online and it seems it is just intended to display it and not do anything else with it. So far, nothing I tried has worked. Your off the top of your head examples have lots of errors I don't even know how to begin to fix them.

                                    J 2 Replies Last reply
                                    0
                                    • S samflex

                                      Thanks a lot for all your help, jkirkerx. I am beginning to think this is not even possible. I have looked at several examples online and it seems it is just intended to display it and not do anything else with it. So far, nothing I tried has worked. Your off the top of your head examples have lots of errors I don't even know how to begin to fix them.

                                      J Offline
                                      J Offline
                                      jkirkerx
                                      wrote on last edited by
                                      #18

                                      It can be done. We do this on a volunteer basis, we don't get paid. I'm not a retired person, I'm actually working on my jobs that I have to get finished while I'm trying to help you. Your in the learning phase, and you don't quite understand HTML and the DOM, and how Java Script is just a DOM manipulator. This happens with programmers that know how to write code, but don't know HTML very well, and downplays the significance of HTML as a language. PHP is classic for this. I see PHP programmers write elaborate code to generate HTML, instead of just writing a HTML page, with a little PHP to generate a little bit of HTML.

                                      1 Reply Last reply
                                      0
                                      • S samflex

                                        Thanks a lot for all your help, jkirkerx. I am beginning to think this is not even possible. I have looked at several examples online and it seems it is just intended to display it and not do anything else with it. So far, nothing I tried has worked. Your off the top of your head examples have lots of errors I don't even know how to begin to fix them.

                                        J Offline
                                        J Offline
                                        jkirkerx
                                        wrote on last edited by
                                        #19

                                        [EDIT] I fixed your code, and now it works. I don't really code in c#, and can't figure out why I have to click the button twice to populate the blue textbox, the postback results of the client script. Maybe someone else can give me some insight into this. but like I said, I didn't see any asp.net in your first post, so it really seems like a javascript issue. In hindsight, it looks you you pasted a bunch of code from the inter webs on to a web form, expecting it to work, without solid knowledge of how java script works, and how to adjust asp.net to it for the postback value to do whatever you need to do with it. I can tell that you have very little experience with client scripting and asp.net, and could use a little more time and practice on that subject. Like I said last night, it was just concept code, you were not suppose to copy and paste it into your work. You were suppose to see the difference and type that into your project.

                                        <%@ Page Language="C#" AutoEventWireup="true" %>

                                        <!DOCTYPE html>
                                        <script runat="server">

                                        protected void bt\_search\_Click(object sender, EventArgs e)
                                        {
                                            if (Page.IsPostBack)
                                            {
                                                String m\_results = txt\_results.Text;
                                                txt\_postback.Text = m\_results;
                                        
                                            }
                                        }
                                        

                                        </script>

                                        <html xmlns="http://www.w3.org/1999/xhtml">
                                        <head id="Head1" runat="server">
                                        <title></title>
                                        <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j\_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>

                                        <script type="text/javascript">
                                        
                                            var geocoder, location1, location2;
                                        
                                            function initialize() {
                                                geocoder = new GClientGeocoder();
                                            }
                                        
                                            function showLocation() {
                                        
                                                var vFlag = true;
                                        
                                                geocoder.getLocations(document.getElementById('txt\_address1').value, function (response) {
                                                    if (!response || response.Status.code != 200) {
                                                        alert('Sorry, we were unable to geocode the first address');
                                                        vFlag = false;
                                                    }
                                                    else {
                                        
                                                        location1 = { lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address };
                                                        geocoder.getLocations(document.getElementById('txt\_address2').value, function (response) {
                                        
                                        S 2 Replies Last reply
                                        0
                                        • J jkirkerx

                                          [EDIT] I fixed your code, and now it works. I don't really code in c#, and can't figure out why I have to click the button twice to populate the blue textbox, the postback results of the client script. Maybe someone else can give me some insight into this. but like I said, I didn't see any asp.net in your first post, so it really seems like a javascript issue. In hindsight, it looks you you pasted a bunch of code from the inter webs on to a web form, expecting it to work, without solid knowledge of how java script works, and how to adjust asp.net to it for the postback value to do whatever you need to do with it. I can tell that you have very little experience with client scripting and asp.net, and could use a little more time and practice on that subject. Like I said last night, it was just concept code, you were not suppose to copy and paste it into your work. You were suppose to see the difference and type that into your project.

                                          <%@ Page Language="C#" AutoEventWireup="true" %>

                                          <!DOCTYPE html>
                                          <script runat="server">

                                          protected void bt\_search\_Click(object sender, EventArgs e)
                                          {
                                              if (Page.IsPostBack)
                                              {
                                                  String m\_results = txt\_results.Text;
                                                  txt\_postback.Text = m\_results;
                                          
                                              }
                                          }
                                          

                                          </script>

                                          <html xmlns="http://www.w3.org/1999/xhtml">
                                          <head id="Head1" runat="server">
                                          <title></title>
                                          <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j\_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>

                                          <script type="text/javascript">
                                          
                                              var geocoder, location1, location2;
                                          
                                              function initialize() {
                                                  geocoder = new GClientGeocoder();
                                              }
                                          
                                              function showLocation() {
                                          
                                                  var vFlag = true;
                                          
                                                  geocoder.getLocations(document.getElementById('txt\_address1').value, function (response) {
                                                      if (!response || response.Status.code != 200) {
                                                          alert('Sorry, we were unable to geocode the first address');
                                                          vFlag = false;
                                                      }
                                                      else {
                                          
                                                          location1 = { lat: response.Placemark\[0\].Point.coordinates\[1\], lon: response.Placemark\[0\].Point.coordinates\[0\], address: response.Placemark\[0\].address };
                                                          geocoder.getLocations(document.getElementById('txt\_address2').value, function (response) {
                                          
                                          S Offline
                                          S Offline
                                          samflex
                                          wrote on last edited by
                                          #20

                                          jkirkerx, I THANK YOU so much for your assistance but more importantly. I have been extremely fortunate and blessed to work with people who demonstrate a great deal of patience with determination to help someone else succeed. I really appreciate it. About asp.net, no I am not a newbiew at all. There are two things I can say I am good at; asp.net and sql are two of them. As for Javascript, yes, I am not very good there. Having said that, usually, before I post, I scoured the web looking for snippets or samples to use. So, when I post, I post because I tried to solve it myself. As I stated earlier, I was looking for a way to give us the ability to calculate mileage between two locations. My googling took me to the sample Javascript I posted. Yes, you are right, the Javascript is mine but I tested it and it works. However, I was looking for a way to use it with Multiview control. I did mention that remember? With multiview control, you have view1, view2, viewN. In my case, I have view1 called vwPersonalData. With this, users enter all their information and when they click NEXT, they are taken to view2 called vwPreviewData. As the name suggests, they can preview the information they entered in vwpersonalDate. If something is not right, they go back, correct it then try again. If all is well, they click SUBMIT to submit to the database. Everything works except this javascript bit. I didn't want to dump all of that code here. So, I started with Javascript per your suggestion so I can go one step at a time. I am about to try to integrate your solution with multiview controls and see if i can do it. Again, you are God sent and I thank you very much. Be back with results.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups