close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Dynamic input script/form

Thread began 5/28/2009 3:09 am by secure377208 | Last modified 6/17/2009 10:31 am by Ray Borduin | 3188 views | 7 replies |

secure377208

Dynamic input script/form

I would like to provide a couple of input boxes on a page which will allow a user to enter their street and postcode to allow directions to be generated to a set location, having no php knowledge or experience beyond cut and paste could someone point me in the right direction on how to create the facility, or is their a pre prepared script which could be used anywhere.

I would think that this is a common requirement but cannot find anything within support which provides a default or demo template for this.

Any help would be appreciated.

Thanks

Sign in to reply to this post

Ray BorduinWebAssist

Create the page as you want it to look first. Once you are done, then add the map and specify the from directions to come from the form you just designed.

Sign in to reply to this post

secure377208

directions location from form input

As mentioned we do not have php experience so I was hoping for something a bit beyond the theory, I have managed to cobble together this basic script (below) which allows input of the postcode and then places the postcode onto the page which although crude does work.

What I need to know is what is the correct syntax to input this variable into the maps postcode field on the directions page ( I am aware that I need to use the value ".$Pcode." but do not know what the syntax should be to get it into google maps.

I am hoping that it is all as simple as I have imagined.

Any help would be appreciated.

Thansk in advance

<?php
$Pcode = $_POST["Pcode"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>map test</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Post Code:<input type="text" size="12" maxlength="12" name="Pcode"><br />

<input type="submit" value="submit" name="submit">
</form>
<p>
<?
} else {
echo "Your postcode is ".$Pcode." .<br />";
{
echo $f."<br />";
}
echo "<i>".$quote."</i><br />";

}
?>

Sign in to reply to this post

Ray BorduinWebAssist

Open the google maps interface and you should be able to click on the lightning bolt and choose to get the directions from information from the form you have created.

The syntax would be:

<?php echo($Pcode); ?>
or you don't to add the code and you could reference the form element directly like:

<?php echo(isset($_POST["Pcode"])?$_POST["Pcode"]:""); ?>

Sign in to reply to this post

secure377208

still not working

Hi Ray,
I am having extreme problems trying to get this to work, on the face of it it seems as though it should be so simple and I am sure it is a regular requirement for users so I am suprised that you do not have a working template to demonstrate the facility.

At present I am happy to accept that my lack of php knowledge is the cause of the issue but having experienced a number of issues with this program in the past which havent been my fault but program anomolies (you may recall that the multiple dynamic locations doesn't work reliably and the inability to re-edit maps if the containing pages are within a sub folder) I am fast losing not only confidence but the will to live and am seriously considering looking at other products which do the same things in the hope that they will work better for me.

I dont expect you to teach clients php but would expect that you have an interest in ensuring that clients can use the programs without too many hassles in order to prevent product dissatisfaction, after all you do market your products for use by those who do not have programming skills.

Anyway gripe over, back to business, I have listed my issues below.

a) Tried using your suggestion of the lightning bolt to add the variable however if I select this the code produced is
<?php echo((isset($_POST["Pcode"]))?$_POST["Pcode"]:"") ?>
which is different to your advice of
<?php echo(isset($_POST["Pcode"])?$_POST["Pcode"]:""); ?> due to the extra set of brackets, although I cannot get it to work using either, it would be helpful to know which is correct.

b) Having got the simple form to echo the information input into the postcode field I then add the google map but find that the map displays on the form input screen and has somehow produced directions from Scotland to my fixed point, I can only assume that the map has somehow tried to interpret the variable in its native form as a postcode location as at this point a postcode hasn't been input into the form.

c) I input a postcode but the map and directions do not display on the resulting page but the postcode does display as per the input script, I have tried placing the map in different locations throughout the code but get syntax errors due to my lack of php knowledge in not knowing what should go where.

As I have already experienced issues with the program caused by the location of the <script type="text/javascript" src="google_javascript/wagmp_maps.js">/*wagmp*/</script> code being automatically placed at the foot of the page causing an inability to re-edit some maps which is only overcome by placing the code directly under the map id and style code and ensuring that the map style and the directions code are not split onto seperate lines I am obviously concerned that my issues could possibly be due to more anomalies with the program.

In effect the map is displaying before the variable is filled, but does not display afterwards on the page which is created by the script showing the form result.

My requirement is that the map should only display after the postcode value has been entered (on the results page) in the same way that that the script produces the echo statement showing the input, You can see this here dir.php

where do I need to place the google map

<div id="wagmp_map_4" style="width: 300px; height: 300px;"></div><div id="wagmp_directions_4"></div>
<script type="text/javascript" src="google_javascript/wagmp_maps.js">/*wagmp*/</script>

code to achieve this effect? Do I need to have the input and the results as two different pages to get it to work?

Given the work you have put into support for the products I am extremely suprised that you have not created a simple demo template providing this functionality as I am sure it would be helpful to many clients as I cannot find any documentation on your site supporting this requirement.

I really dont want to have to give up on this as it seems such a simple task but I am finding it hard to justify the time and obviously the time difference with support doesn't help so any help you or anyone else can provide would be appreciated.

Thanks in advance.

Sign in to reply to this post

Ray BorduinWebAssist

a) I believe both syntax's will work. The parenthasis are essentially unneeded placeholders. Certainly use the one from the bindings and not the one I wrote since it would be the better tested syntax.

b) The map is picking up the hard coded country setting in the default from address. The starting location is the default location returned with the address: "United Kingdom"... which you have hard coded as the start field.

c) You can probably leave the country field blank, or use something like:
<?php echo((isset($_POST["Pcode"]))?"United Kingdom":"") ?>

That way the country won't be filled in if the pCode isn't included.

Sign in to reply to this post

secure377208

still have issues

Hi Ray,
Thanks for the pointers, however we havent dealt with the main issue which is in item c)

my script to take the input postcode and echo it onto the screen works but because the map is displaying on the input screen rather than after the submit button has been pressed it isnt picking up the postcode variable and the map doesn't display at all on the screen where the script does succesfully echo the postcode onto the screen which you would have seen if you had followed the above link, therefore my question again is;

In the code below where do we need to place the map code in order to have it display after the data entry and the submit button has been pressed and do we need to add extra elements to the script in order to get it to work?

<?php
$Pcode = $_POST["Pcode"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>map test</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Post Code:<input type="text" size="12" maxlength="12" name="Pcode"><br />

<input type="submit" value="submit" name="submit">
</form>
<p>
<?
} else {
echo "Your postcode is ".$Pcode." .<br />";
{
echo $f."<br />";
}
echo "<i>".$quote."</i><br />";

}
?>

Sign in to reply to this post

Ray BorduinWebAssist

The correction is not made in this code. It would be made in the pro maps code included on the page.

Post that and I could advise what needs to be updated.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...