Solved

CFSELECT and Show/Hide DIV

Posted on 2012-04-03
8
776 Views
Last Modified: 2012-04-03
If I choose option value 1, from the "First select"
results from both div id="d0" and div id="d1" are sent via a form.

First select:
<SELECT id="ptype" NAME="business_category_main" onchange="toggleSubmit(this)">
<option value="1">Culture, Entertainment & Recreation</option>
<option value="2">Drinking & Dining</option>
</select>


Second select:
<div id="d0" style="display:block">
<select  class="wpcf7-text textbox" name="business_subcategory">
<option VALUE="1">Art Studios, Galleries & Artists</option>
<option VALUE="2">Movie Theaters</option>
<option VALUE="3">Fitness, Sports & Recreation</option>
<option VALUE="4">Performance Venues</option>
<option VALUE="5">Travel & Lodging</option>
</select></div>
<div id="d1" style="display:none">
<select  class="wpcf7-text textbox" name="business_subcategory">
<option VALUE="6">Cafes & Bakeries</option>
<option VALUE="7">Catering</option>
<option VALUE="8">Delis & Grocers</option>
<option VALUE="9">Restaurants & Eateries</option>
<option VALUE="10">Bars, Taverns & Lounges</option>
<option VALUE="11">Wine, Liquor & Spirits</option>
</select></div>
0
Comment
Question by:swaggrK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 37801727
What is your question?
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37801731
Check out this jsfiddle:

The code is:

function toggleSubmit(caller) {

    $("#d0").toggle();
    $("#d1").toggle();

}

Open in new window

0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37801864
...or jsfiddle if you want the select removed:

The code is:

function toggleSubmit(caller) {

    $("#d0").toggle();
    $("#d1").toggle();

}

function onSubmit() {

    $("#d0").not(":visible").remove();
    $("#d1").not(":visible").remove();

}

Open in new window

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:swaggrK
ID: 37801877
hmm... testing what u sent. I forgot to include the following in my initial post...
Basically, it is not submitting just ONE result but a result from "d0" and "d1"

<script type='text/javascript'>

function toggleSubmit(obj){

count=0
while(document.getElementById("d"+count)){
document.getElementById("d"+count).style.display="none"
count++
}
document.getElementById("d"+obj.selectedIndex).style.display="block"

}
</script>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37801936
Edit: Doh, just realized you're hiding the DIV not the select lists. Try the previous suggestion.
0
 
LVL 20

Accepted Solution

by:
Proculopsis earned 150 total points
ID: 37802038
The newer version removes the unused select from the form.
0
 

Author Comment

by:swaggrK
ID: 37802051
AGX, that may work, but the results are submitted as followed...

1,6

With 1,6 being
<option VALUE="1">Art Studios, Galleries & Artists</option>
and
<option VALUE="6">Cafes & Bakeries</option>

Not sure how I would write a cfif that would take the 1 or the 6


<div id="d0" style="display:block">
<select  class="wpcf7-text textbox" name="business_subcategory">
<option VALUE="1">Art Studios, Galleries & Artists</option>
<option VALUE="2">Movie Theaters</option>
<option VALUE="3">Fitness, Sports & Recreation</option>
<option VALUE="4">Performance Venues</option>
<option VALUE="5">Travel & Lodging</option>
</select></div>
<div id="d1" style="display:none">
<select  class="wpcf7-text textbox" name="business_subcategory">
<option VALUE="6">Cafes & Bakeries</option>
<option VALUE="7">Catering</option>
<option VALUE="8">Delis & Grocers</option>
<option VALUE="9">Restaurants & Eateries</option>
<option VALUE="10">Bars, Taverns & Lounges</option>
<option VALUE="11">Wine, Liquor & Spirits</option>
</select></div>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37802101
Actually I missed the earlier part about hiding the div, not the lists. Try hiding the select lists instead. I believe they won't show up on the action page if they're not visible.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question