Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help with placing values

    Hello,

    I have following javascript that loads a streetmap:


    Code:
    <script type="text/javascript">
    geoportaal_type          = "gemeente";
    geoportaal_id            = "blankenberge";
    geoportaal_startupmodule = "stratenatlas";
    geoportaal_bgcolor       = "FFFFFF";
    </script>
    <script type="text/javascript" src="http://www.geoportaal.be/syndication/toonportaal.js"></script>
    What I want to do is pretty simple: create a little searchbox on my homepage where people can enter their streetname and housenumber and the map loads.
    To do this i use following code related to a script:



    Code:
    <script type="text/javascript">
    geoportaal_niscode       = "vilvoorde";
    geoportaal_startupmodule = "stratenatlas";
    geoportaal_bgcolor       = "FFFFFF";
    geoportaal_request_name  = "toonadres";
    geoportaal_request_parameters = "straat=Kerkstraat&huisnr=1"; </script> <script src="http://www.geoportaal.be/syndication/toonportaal.js"></script>
    Basically the same as mentioned earlier, though some other tags must be used.
    How do I create the fields (values) to enter the text and the OK-button to confirm the search?
    When users press the OK-button the script must load.

    When loading, following values are important:


    geoportaal_request_parameters = "straat=Kerkstraat&huisnr=1where straat=VALUE1&huisnr=VALUE2
    So:
    VALUE1=streetname
    VALUE2=housnumber

    All I need is the script to take the values entered by the users and to paste these values on the right place (code above).
    How do i do this, do i need an onclick-handler for this?

    This is html-code for the searchbox but no actions are defined yet:


    Code:
    <div id=locationsearch>
    <table id="form">
    <tr><td>Straatnaam:</td><td><form id="form1" name="form1" method="post" action="">
        <label>
          <input type="text" name="straat" id="VALUE1" />
        </label>
      </form></td></tr>
    <tr><td>Huisnummer:</td>
    <td><form id="form2" name="form2" method="post" action="">
      <label>
          <input type="text" name="huisnr" id="VALUE2" />
        </label>
      </form></td></tr>
    <tr><td>&nbsp;</td><td><form id="form3" name="form3" method="post" action="">
      <label>
        <input type="submit" name="toonadres" id="toonadres" value="Lokaliseer" />
      </label>
    </form></td></tr>
    </table>
    </div>
    Please advise from A to Z. I'm a novice.

    Thank you in advance,

    William.

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Posts
    568
    Thanks
    6
    Thanked 84 Times in 84 Posts
    I have had a look at the geoportaal script and it looks like the function that inserts the map is GeoPortalSyndication.writeInpage.

    The instance created by their script is anonymous, so I think you will have to create a new one each time you reload the map.

    It would probably be best to keep this out of a <form>, but here I've changed the submit button input type to "button" to stop it from submitting (forms allow quicker syntax for accessing elements).

    Something like this:

    Code:
    <form name="locationsearch">
    	<input type="text" name="straat">
    	<input type="text" name="huisnr">
    	<input type="button" onclick="loadMap()" value="Lokaliseer">
    </form>
    Code:
    function loadMap() {
    	var straat=document.locationsearch.straat.value;
    	var huisnr=document.locationsearch.huisnr.value;
    	geoportaal_request_parameters="straat="+straat+"&huisnr="+huisnr;
    	new GeoPortalSyndication().writeInpage();
    }
    PS.

    Code:
    <label>
    <input type="text" name="straat" id="VALUE1" />
    </label>
    Labels are used as handles for form elements (you click the label to focus the element) eg.

    Code:
    <label for="VALUE1">Straat: </label>
    <input type="text" name="straat" id="VALUE1" />
    Also, forms can contain pretty much any element (block or inline), so it would be easier just to have one form with a table inside it for formatting.

    Gus
    Last edited by gusblake; 01-31-2010 at 05:38 PM.

  • Users who have thanked gusblake for this post:

    WilliamV (01-31-2010)

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Dear Gus,

    I'll apply your suggestions and will keep you informed of the further progress.

    I thank you again for your time and effort and the 'clear' explications.

    Sincerely,

    William.

  • #4
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hello Gus,

    I've applied your suggestions and I'm having following problem:
    When I fill in the street and housenumber i get following error (from browser)

    Bericht: 'document.locationsearch.straat' is empty or has no object.
    Regel: 80
    Teken: 2
    Code: 0
    URI: http://www.blankenberge.be/js/naamloos-1.js
    What have i done:

    1. I've added your function to the existing javascript.

    2. I've placed following script and html-code on my page:

    Code:
    <script type="text/javascript" src="/js/naamloos-1.js"></script></p>
    <form name="locationsearch">
        <input name="straat" type="text" /> <input name="huisnr" type="text" /> <input type="button" onclick="loadMap()" value="Lokaliseer" />
    </form>
    naamloos-1.js is the same as the original script but with your added function.

    What am i doing wrong?

    I also forgot to mention that
    Code:
    geoportaal_request_name  = "toonadres";
    is crucial for the street and housenumber to show.
    'Toonadres' means 'Showadress'.
    e.g.
    Code:
    <script type="text/javascript">
    geoportaal_niscode       = "blankenberge";
    geoportaal_startupmodule = "stratenatlas";
    geoportaal_bgcolor       = "FFFFFF";
    geoportaal_request_name  = "toonadres";
    geoportaal_request_parameters = "straat=Kerkstraat&huisnr=1"; </script> 
    <script src="http://www.geoportaal.be/syndication/toonportaal.js"></script>
    This code would load the map with "straat=Kerkstraat&huisnr=1".

    To visualise this script, you can click here. It's a service provided to the customers. We only want to create a little search-widget for our visitors which loads the map.

    Also, the script automatically loads. Which function do i need to change to avoid this for making the search-widget work? Or how do i invoke the loading of the script?


    Thank you in advance for your time and effort. I really appreciate this.

    Sincerely,

    William.
    Last edited by WilliamV; 02-01-2010 at 02:13 PM. Reason: Make things more clear

  • #5
    Regular Coder
    Join Date
    Jan 2006
    Posts
    568
    Thanks
    6
    Thanked 84 Times in 84 Posts
    Is the function called before the form exists (with an onload)? I can't think what else could be going wrong.
    Last edited by gusblake; 02-01-2010 at 02:45 PM.

  • #6
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I think yes, the script loads with onload, though i don't know how to load the script afer the button is clicked?

    I'm not a real java-programmer so...

    I just changed the earlier post to clarify some things.

    Thank you again to take a look at this case!
    Sincerely,

    William.
    Last edited by WilliamV; 02-01-2010 at 02:19 PM.

  • #7
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Can you take a look again?


  •  

    Posting Permissions

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