Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:18:22+00:00 2026-06-14T23:18:22+00:00

I have a form with 4 dropdowns and a submit button. When a user

  • 0

I have a form with 4 dropdowns and a submit button. When a user clicks the submit button I want to go to my controller handling the input/output giving the users choices, but with a correct URI.

The dropdowns are dynamically generated from Ajax depending on the users choices, bar the first dropdown. They are working absolutely fine.

The method handling the user input is located in this controller: /app/controllers/shop/kategorier, index method looks like this:

public function index($fabrikat, $type, $model, $produktnr = '0')
{
    // get all the data from the model
    $data['all'] = $this->fetch->get_kategorier($fabrikat, $type, $model, $produktnr);

    print_r($data['all']);      
}

My goal is this: When users hit the submit button, I wan’t them to view the page with that exact URL including the parameters, eg. http://app.com/shop/kategorier/index/LG/WASH/FL9834X/0/ That’s all I really want.

Note: Accessing this URL manually works fine, and the controller/model handles the parameters as they should.

How do I accomplish this? I tried two things, they both failed. Sort of.

  1. I tried with jQuery, and generated a encodedURL string with all the
    parameters with a ‘/’ delimiter, and changed the .attr(‘href’) on
    submit. But that was a nightmare, since some of the $model’s can be
    eg. 'CE1000C-T / XEE' etc.

  2. I tried to make a ‘proxy’ method in the Kategorier
    controller taking all the input->posts and appending them to a
    redirect('kategorier/'.$fabrikat.'/'.$etc), but that was rather
    stupid.

I would rather not use query strings like /kategorier?fabrikat=LG&type=WASH etc

My form looks like this:

<?php echo form_open('shop/kategorier/'); ?>

<select id="fabrikat" name="fabrikat">
    <option name="0">Vælg Fabrikat</option>
    <?php foreach ($fabrikater as $f) : ?>
        <option value="<?php echo $f->Fabrikat; ?>" name="<?php echo $f->Fabrikat; ?>"><?php echo $f->Fabrikat; ?></option>
    <?php endforeach; ?>
</select>

<select id="type" name="type">
</select>

<select id="model" name="model">  
</select>

<div id="produktnummer-wrap" style="display:none">
    <select id="produktnummer" name="produktnummer">
        <option name="0" value="">Vælg Produktnummer</option>
    </select>
</div>

<?php echo form_submit('findparts', 'Find Reservedele'); ?>
<?php echo form_close(); ?>

I believe I’m somehow overcomplicating things, but right now I can’t think straight. I will be more than happy to elaborate anything.
I really hope someone is able to help me out, thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:18:23+00:00Added an answer on June 14, 2026 at 11:18 pm

    @Repox I did figure out an approach last night which was actually pretty similar to your solution. Here’s what I did:

    $("#find-btn").on("click", function() {
        var fab = $("select#fabrikat").val();
        var type = $("select#type").val();
        var model = $("select#model").val();
        var produktnummer = $("select#produktnummer").val();
    
        // we have to replace spaces in models and types
        model = model.replace(/\s+/g, '-');
        type = type.replace(/\s+/g, '-');
    
        // produktnummer can be empty
        produktnummer = (produktnummer === '') ? "0" : produktnummer;
    
        // we also have to URI encode the model and prodnr since it
        // can be horror strings like 'xy762 / ø23'
        model = encodeURIComponent(model);
        produktnummer = encodeURIComponent(produktnummer);
    
        // our url string to update the href
        var url = fab + '/' + type + '/'  + model + '/'  + produktnummer;
    
        // update the href with the specific parameters
        $(this).attr("href", "http://app.dev/kategorier/index/"+url);
    });
    

    Although I need to be very wary when handling the parameters in my controllers and models, they need to be encoded and decoded correctly afterwards. A slight portion of the model strings could be something like:

    ‘EX+ 340-34 / Ø14’ OR ‘77773+ -/ 23IK’

    Which isn’t ideal with the decoding in my controller using str_replace('-', ' ', $str); I therefore need to examine lots of the data before choosing a replacement character.

    However, this is probably the best solution if one wishes to do this without having to use query strings in Codeigniter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my website I have several input fields in a form. I want the
I have a fancybox that is shown when a user clicks a button. The
I have a form, which has lists, and a submit button, when an item
Let's assume I have a very simple form, with a submit button and a
I have a form with 4 dropdowns on it. The default selected option in
I have a form with multiple dropdowns consisting of multiple values. I'm trying to
I have a form where I have 4 dropdowns Country, State, District and City.
I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
I have a select form field that I want to mark as readonly, as
The following example displays a modal dialog box when the user clicks the button.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.