close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

pre populating drop down

Thread began 8/19/2014 5:57 am by Jamie | Last modified 8/19/2014 12:58 pm by Jason Byrnes | 2269 views | 8 replies |

Jamie

pre populating drop down

Hey Jason

Just wondering if this is possible and, if so, how to go about doing it.

I have a contact form that has a drop down selector for different sectors of the business

On every page there is a CTA 'get a quote' which links to the contact page and the form above.

Is there any way to somehow allow that when you are on, for example, section A of the companies wewbsite, if the visitor clicks the CTA that the drop down on the form pre populates with the correct selection. If the visitor comes to the form from a non section page (eg the homepage) that nothing happens and the dropdown stays is is with 'please select'?

Many thanks

Jamie

Sign in to reply to this post

CraigRBeta Tester

could you add a different 'get' parameter to each of the links, and on the contact page, check to see if a 'get' value has been passed, and select accordingly ?

Sign in to reply to this post

Jason ByrnesWebAssist

CraigR's suggestion is the way to go.

Sign in to reply to this post

Jamie

Thanks to you both....how would I do that please?

Sign in to reply to this post

CraigRBeta Tester

Let's say your select list has options 1, 2 and 3

<select>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>



On your link, you could use option as a parameter.

<a href="contact.php">

becomes

<a href="contact.php?option=1">

Then, on the select list on the conatct page, click the dynamic button in properties, and on 'select value equal to' at the bottom, type $_GET['option'] or whatever you called the parameter

(sorry, but I can;t test this at the moment as my computer is being difficult, apologies in advance for any typos/errors)

Sign in to reply to this post

Jamie

Many thanks Craig

I have tried that but there was already <?php (isset($_GET["invalid"])?ValidatedField("contact","Section"):"") ?> within the select value equal to. I have tried replacing it with $_GET['option'] entirely and also just replacing invalid with option... neither work

these are the options I am working with

<option id="" value="No selection made" selected>Please Select</option>
<option value="Commercial" <?php if (!(strcmp("Commercial", (isset($_GET["invalid"])?ValidatedField("contact","Section"):"")))) {echo "selected=\"selected\"";} ?>>Commercial</option>
<option value="Domestic" <?php if (!(strcmp("Domestic", (isset($_GET["invalid"])?ValidatedField("contact","Section"):"")))) {echo "selected=\"selected\"";} ?>>Domestic</option>
<option value="PestControl" <?php if (!(strcmp("PestControl", (isset($_GET["invalid"])?ValidatedField("contact","Section"):"")))) {echo "selected=\"selected\"";} ?>>Pest Control</option>
<option value="CleaningProducts" <?php if (!(strcmp("CleaningProducts", (isset($_GET["invalid"])?ValidatedField("contact","Section"):"")))) {echo "selected=\"selected\"";} ?>>Cleaning Products</option>



I have also removed the validation from each one and using :

<option id="" value="No selection made" selected <?php if (!(strcmp("No selection made", "$_GET[\'option\']"))) {echo "selected=\"selected\"";} ?>>Please Select</option>
<option value="Commercial" <?php if (!(strcmp("Commercial", "$_GET[\'option\']"))) {echo "selected=\"selected\"";} ?>>Commercial</option>
<option value="Domestic" <?php if (!(strcmp("Domestic", "$_GET[\'option\']"))) {echo "selected=\"selected\"";} ?>>Domestic</option>
<option value="PestControl" <?php if (!(strcmp("PestControl", "$_GET[\'option\']"))) {echo "selected=\"selected\"";} ?>>Pest Control</option>
<option value="CleaningProducts" <?php if (!(strcmp("CleaningProducts", "$_GET[\'option\']"))) {echo "selected=\"selected\"";} ?>>Cleaning Products</option>



but that just generates the following error: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/gahel6wj/public_html/contact2.php on line 313

Sign in to reply to this post

Jason ByrnesWebAssist

this code:
<?php if (!(strcmp("Commercial", (isset($_GET["invalid"])?ValidatedField("contact","Section"):"")))) {echo "selected=\"selected\"";} ?>

should add the option URL perameter as the false part:

<?php if (!(strcmp("Commercial", (isset($_GET["invalid"])?ValidatedField("contact","Section"):(isset($_GET['option'])?$_GET['option']:"")))) {echo "selected=\"selected\"";} ?>

Sign in to reply to this post

Jamie

Thats awesome

Thanks

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

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...