Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt 353 posts 825 karma points
    Sep 18, 2020 @ 10:57
    Matt
    0

    Hello,

    So I'm working on a list of departments, what I want todo is render the departments in a dropdown list, which once somebody selects that node I want it to take them to the page.

    How can I achive this? I've got my departments renders out using a form in a dropdown box, but just need help with the next step.

    <form id="email-form" name="email-form" data-name="Email Form" class="form">
                    <h2 class="heading-6">Search for Departments, Wards and Services</h2>
                    <label for="name">Name</label>
                    <input type="text" class="text-field w-input" maxlength="256" name="name" data-name="Name" placeholder="Type search keywords (e.g &#x27;Outpatients&#x27;)" id="name">
      @******************** List Departments Start *******************@ 
                    <label for="email">Select department (optional)</label><select id="field-3" name="field-3" data-name="Field 3" class="text-field w-select">
                        <option value="">Select one...</option>
                        @{
        var getDepartments = Umbraco.Content(Guid.Parse("2d0a41a3-9e4f-480a-bf79-741c67b72037"))
        .Children()
        .Where(x => x.IsVisible());
    }
    
        @foreach (var item in getDepartments)
        {
                 <option value="">@item.Name</option>
        }
                        </select>
     @******************** List Departments End *******************@ 
    
    
                  </form>
    

    Thanks

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Sep 18, 2020 @ 14:19
    Steve Morgan
    0

    Hi,

    You need javascript. Something like:

    <select id="selectbox" name="" onchange="javascript:location.href = this.value;">
       @* your foreach loop *@
            <option value="@item.Url">@item.Name</option>
        @* } *@
    </select>
    
Please Sign in or register to post replies

Write your reply to:

Draft