ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Passing form values to URL Segments

February 02, 2013 6:54am

Subscribe [3]
  • #1 / Feb 02, 2013 6:54am

    jonwrightmedia

    75 posts

    I am putting together a simple form, which I don’t require to do anything but pass on the values selected in the select fields onto URL segments.

    I’m a bit stuck on how to go about this.

    I want to pass date values on (year, month, day), so that the URL may end up like this:

    http://www.mysite.com/2013/12/12/.

    Any suggestions?

  • #2 / Feb 02, 2013 10:30am

    Bhashkar Yadav

    727 posts

    Hi,

    You can do it with the help of JavaScript or JQuery like:

    $('#SUBMIT_BUTTON_ID').click(function(){  
            [removed]='http://www.mysite.com/' + $('#YEAR_FIELD_ID').val() + '/' + $('#MONTH_FIELD_ID').val() + '/' + $('#DAY_FIELD_ID').val();
    });

    I hope, it would help you.


    Best Regards,

  • #3 / Feb 02, 2013 10:32am

    jonwrightmedia

    75 posts

    Thanks so much Bhashkar, I’ll give that a try,

  • #4 / Feb 02, 2013 10:44am

    jonwrightmedia

    75 posts

    That didn’t work and I’m not sure why, here is my code, I’m probably being dumb and missing something obvious.

    [removed]
         $('#date-search').click(function(){  
            [removed]='http://www.chocolateweek.co.uk/' + $('#year').val() + '/' + $('#month').val() + '/' + $('#day').val();
    }); 
     [removed]
    
    <form id="search-events" method="get" acti>
     <select name="year" class="year" id="year">
      <option value="2013">2013</option>
     </select>
     <select name="month" class="month" id="month">
      <option value="">Month</option> 
      <option value="01">01</option>
     </select>
     <select name="day" class="day" id="day">
      <option value="">Day</option>
      <option value="01">01</option>
     </select>
     <select name="selpar" class="home-signup">
     <option value="">Select Participant</option>
      {exp:channel:entries channel="participants" dynamic="off" orderby="title" sort="asc" status="Open|Featured" limit="300"}
       <option value="{entry_id}">{title}</option>
      {/exp:channel:entries}
     </select>
     <input type="submit" id="date-search" />
    </form>
  • #5 / Feb 02, 2013 10:45am

    Bhashkar Yadav

    727 posts

    ahh, just noticed [removed] is being removed in code view and replaced with [removed] 😉.


    Best Regards,

  • #6 / Feb 02, 2013 10:46am

    jonwrightmedia

    75 posts

    Just saw that too, what was in the place of removed?!

    😛

  • #7 / Feb 02, 2013 10:51am

    Bhashkar Yadav

    727 posts

    Can you do anything alert within the click event and it would be better if you remove the <form>. There is no need for this tag.

     

  • #8 / Feb 02, 2013 10:57am

    jonwrightmedia

    75 posts

    Hmm, no alert either, the temporary test page is here, if you don’t mind taking a look….?

    http://www.chocolateweek.co.uk/events/date_participants/

  • #9 / Feb 02, 2013 11:30am

    Bhashkar Yadav

    727 posts

    it seems that there is some JQuery conflict. So we can use JavaScript for this simple event. Just add onclick event to submit button like :

    <input type="submit" id="date-search"  />


    Now you need to have JS code like

    function redirect_page()
     {
      [removed] ='http://www.chocolateweek.co.uk/' + document.getElementById("year").value + '/' + document.getElementById("month").value + '/' + document.getElementById("day").value; 
     }

    Just looked that code is removed from code view so please look at attached image.

    Best Regards,

  • #10 / Feb 02, 2013 12:09pm

    jonwrightmedia

    75 posts

    Thanks for taking the time to have a look, and for your wisdom!

    I’ll give that a try.

  • #11 / Feb 13, 2013 7:35am

    tvoyatema

    1 posts

    Nice to meet you all! wellcome to our resorces: http://www.rosautopark.ru and www.tvoya-tema.ru

  • #12 / Feb 13, 2013 4:54pm

    ahmad saad

    364 posts

    Hi jonparadise2,

    I go to http://www.chocolateweek.co.uk/events/date_participants/ and all I have an empty page .

    this is the problem or this is a new thing??!!!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases