Select "To" in Contact form via Query string

This is a forum to suggest new features for mojoPortal. 

This thread is closed to new posts. You must sign in to post in the forums.
11/26/2010 10:47:35 PM
Gravatar
Total Posts 41

Select "To" in Contact form via Query string

I am in the process of implementing a mojoPortal site (donation on its way soon... seriously, your product just works) and was pleasntly surprised to see that you had the ability to create a drop down of people to email.  Makes it nice to have just one form for a group of people.

However, what I'd like to see is the ability to set the "to" via query string.  So lets say you add a field on the content form settings that allows me to set a query value to make it work.

As an example, lets say I have the following:

Existing fields:
me@me.com|you@you.com|them@them.com
Me|You|Them

New field:

clarence|joe|users

 

Then I could call that page with a url: mydomain.com/emailform.aspx?to=joe

 

Which would cause the drop down to default to "You".

11/27/2010 5:55:46 AM
Gravatar
Total Posts 18439

Re: Select "To" in Contact form via Query string

Sorry but I try to avoid query string params in mojoPortal cms features because they may live on a page with other features. One could have multiple contact forms on the same page even so relying on query string params on cms pages is problematic and can get very messy. It works fine for feature specific supporting pages (like the forums where it links to forum specific pages that are not cms pages, it is ok to use query string params in that situation) but not for the part of the feature that plugs into a cms page. That part of the feature needs to play well with other things on the page and should not expect to have control over the url nor expect extra information being passed in the url.

Best,

Joe

11/27/2010 9:46:52 AM
Gravatar
Total Posts 41

Re: Select "To" in Contact form via Query string

Well... I think it would be a cool feature :-)

I actually made it work, since I have a very simple page that houses my contact form I added an html content part and then put this javascript in it:

<script type="text/javascript">
$(document).ready(function(){
   $('select').get(0).selectedIndex = getParameterByName('p');
 });
function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return 0;
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

</script>

 

So now, the query string "p" will make it change to the person I tell it to change to.

11/27/2010 10:06:12 AM
Gravatar
Total Posts 18439

Re: Select "To" in Contact form via Query string

I'm glad you found a creative solution that worked for you.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.