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

  • SEARCH
  • Home
  • 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 6200769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:25:43+00:00 2026-05-24T04:25:43+00:00

I am using .tmpl() to fill out templates like so <script type=text/x-jquery-tmpl id=template> <form

  • 0

I am using .tmpl() to fill out templates like so

<script type="text/x-jquery-tmpl" id="template">
  <form action="" method="post">
    <div>
      <div> ${ID} </div>
      <div> <input name="title" id="${ID}_title" value="${title}" type="text" /> </div>
      <label> Section (${section}) </label> &nbsp;
      <select name="section" id="${ID}_section">
        <option value="">-- Select --</option>
        <option value="aaa">AAA</option>
        <option value="bbb">BBB</option>
      </select>
    </div>
  </form>
</script>

where ${section} wil contain either the combo box value aaa or bbb.

How do I set the default selection for the combo box according to ${section}?

  • 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-05-24T04:25:44+00:00Added an answer on May 24, 2026 at 4:25 am

    try something like:

    <select name="section" id="${ID}_section">
        <option value="">-- Select --</option>
        <option value="aaa" {{if $section == 'aaa'}} selected="selected" {{/if}}>AAA</option>
        <option value="bbb" {{if $section == 'bbb'}} selected="selected" {{/if}}>BBB</option>
    </select>  
    

    Update
    Well my jsfiddle in comment was just a way to simulate your setup, because you don’t attached it in this post. If $section == bbb or aaa try this:

     <select name="section" id="${ID}_section">
        <option value="">-- Select --</option>
        <option value="aaa" {{if section == 'aaa'}} selected="selected" {{/if}}>AAA</option>
        <option value="bbb" {{if section == 'bbb'}} selected="selected" {{/if}}>BBB</option>
    </select>
    

    Otherwise more code is needed, how do you call your template and how is $section assigned.

    Update 2
    try: http://jsfiddle.net/3TrEY/6/

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

Sidebar

Related Questions

I'm currently generating a list using the jQuery tmpl plugin : <script id=mainTemplate type=text/x-jquery-tmpl>
I noticed that jquery's beta template plugin is using, the type attribute text/x-jquery-tmpl e.g
Using jQuery templates is easy for some simple data structures. <script type=jquery/x-jquery-tmpl id=myTemplate> <li>
I'm using jQuery templates (jquery.tmpl.js) to render content on a webpage and am experiencing
Couldnt find any example on grouping using jquery tmpl() so thought id post what
I have a simple template I'm using a plug in ( Jquery.tmpl() ), and
I am using the jquery-tmpl template library to build a dynamic <select> list. In
I'm using the jQuery template plug-in (official jquery-tmpl plugin) to build up a an
Trying to build dynamic output from json and using jq/template tmpl display rows/columns. Somehow
I ended up using jquery templates and so far everything is working fine, but

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.