Jump to content

Using innerHTML for form and PHP


deruiter2

Recommended Posts

hello,

 

I'm making an app with the google api and php that will locate your location and send this via twitter.

 

Now I want the location being send using a form like this:

 

<script type="text/javascript"

src="http://maps.google.com/maps/api/js?sensor=false">

        </script>

        <script type="text/javascript" src="http://code.google.com/apis/gears/gears_init.js"></script>

        <script type="text/javascript">

var geocoder;

var initialLocation;

var browserSupportFlag =  new Boolean();

var infowindow = new google.maps.InfoWindow()

 

          function initialize() {

  geocoder = new google.maps.Geocoder();

                // Opties voor de kaart, de coordinaten worden het middelpunt

                var myOptions = {

                  zoom: 18, 

                  mapTypeId: google.maps.MapTypeId.HYBRID

                };

                // Maak een nieuwe kaart aan met de ingestelde opties

                var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

 

 

//W3C Geolocation

if(navigator.geolocation) {

browserSupportFlag = true;

navigator.geolocation.getCurrentPosition(function(position) {

initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);

map.setCenter(initialLocation);

// instellen van de marker

var marker = new google.maps.Marker({

position: (initialLocation),

map: map,

title:"Uw positie",

});

document.getElementById('test').innerHTML = initialLocation;

 

}, function() {

handleNoGeolocation(browserSupportFlag);

});

 

The var initialLocation is the var holding the location. I'm sending this via a form to a new php document.

 

<form action="Map3.php" method="post">

  <div id="naam">  Voornaam: <input name="Naamveld" type="text" /><br /></div>

  <div id="lidmaatschap">Lidmaatschapnummer:  <input name="Lidveld" type="text" /><br /></div>

  <div id="kenteken">Kenteken: <input name="Kentekenveld" type="text" /><br /></div>

  <div id="telefoon">Telefoonnummer: <input name="Telefoonveld" type="text" /><br /></div>

  <center><div id="adres">Uw Coördinaten:</div></center>

  <center><div id="test"><input name="geg" id="test"/></div></center>

  <center><input name="Send" type="submit" /></center>

  </form>

 

The next page calls the information from this form and sends this to twitter,

<a href="https://twitter.com/share" class="twitter-share-button" data-text="N: <?php echo $_POST["Naamveld"];?> -- Lid: <?php echo $_POST["Lidveld"]; ?> -- Ken: <?php echo $_POST["Kentekenveld"]; ?> -- Tel: <?php echo $_POST["Telefoonveld"];?> -- adres: <?php echo $_POST["geg"]; ?>" data-count="none" data-via="ANWBtester" data-lang="nl">Tweeten</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>

 

The only problem is that he gets everything from the form into the tweet accept the location.

 

Could anyone help me?

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.