[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 07-06-2008, 04:10 PM   #1 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Quick Question. Hope someone can help

Hey Everyone.

I need to know how in the world I can make it so the 3-6, 6-12, and 12-18 options will only show that white is available. Every other size except these are available in the other colors.

Code:
<td><select name="os1" class="cnt" id="size">
                                            <option>3-6mo</option>
					    <option>6-12mo</option>
					    <option>12-18mo</option>
					    <option>2T</option>
					    <option>3T</option>
					    <option>4T</option>
					    <option>XS</option>
				            <option>S</option>
					 </select>
					 <select name="os0" class="cnt" id="select">
                                                 <option selected>White</option>
                                            <option>Red</option>
                                            <option>Gray</option>
         			 </select>
          <input name="on0" type="hidden" id="on02" value="color" />
		  <input name="on1" type="hidden" id="on12" value="size" />
          <input name="quantity" type="text" id="quantity2" value="1" size="3" maxlength="5" /></td>
                                        </tr>
                                    </table></td>
slipondajimmy is offline  
Old 07-06-2008, 04:33 PM   #2 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services

 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Not the best, but it works.
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html>

<
head>
    <
meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <
title>Untitled 1</title>
    <
script type="text/javascript" language="Javascript">
    function
onlyWhite(select)
    {
        var
select = document.getElementById('size');
        var
value = select.options[select.selectedIndex].value;
        var
cselect = document.getElementById('select');

        if (
value == '3-6mo' || value == '6-12mo' || value == '12-18mo')
        {
            
cselect.options.length = 0;
            
cselect.options[0] = new Option("----------", "-1", false, false);
            
cselect.options[1] = new Option("White", "white", false, false);
        }
        else
        {
            
cselect.options.length = 0;
            
cselect.options[0] = new Option("----------", "-1", false, false);
            
cselect.options[1] = new Option("White", "white", false, false);
            
cselect.options[2] = new Option("Red", "red", false, false);
            
cselect.options[3] = new Option("White", "Gray", false, false);
        }
        return;
    }
    
</script>
</head>

<body>

<select name="os1" class="cnt" id="size" onchange="onlyWhite()">
    <option value="-1">----------</option>
    <option value="3-6mo">3-6mo</option>
    <option value="6-12mo">6-12mo</option>
    <option value="12-18mo">12-18mo</option>
    <option value="2T">2T</option>
    <option value="3T">3T</option>
    <option value="4T">4T</option>
    <option value="XS">XS</option>
    <option value="S">S</option>
</select>
<select name="os0" class="cnt" id="select">
    <option value="-1">----------</option>
    <option value="white">White</option>
    <option value="red">Red</option>
    <option value="gray">Gray</option>
</select>

</body>
</html>
__________________
Eric is offline  
Old 07-06-2008, 04:35 PM   #3 (permalink)
NamePros Member
 
Join Date: Sep 2006
Posts: 87
100.00 NP$ (Donate)

Bruce_KD will become famous soon enoughBruce_KD will become famous soon enough


Code:
<script type='text/javascript'>
function disableColors(select) {
  var sId = select.selectedIndex < 3?true:false;
  var colors = document.getElementById('select');
  colors.options[1].disabled = sId;
  colors.options[2].disabled = sId;  
  if (sId && colors.selectedIndex > 0) colors.selectedIndex = 0;
}

</script>

<select name="os1" class="cnt" id="size" onchange="disableColors(this);">
  <option>3-6mo</option>
  <option>6-12mo</option>
  <option>12-18mo</option>
  <option>2T</option>
  <option>3T</option>
  <option>4T</option>
  <option>XS</option>
  <option>S</option>
</select>

<select name="os0" class="cnt" id="select">
  <option>White</option>
  <option>Red</option>
  <option>Gray</option>
</select>
This basically says:
When you change the size of the shirt, check which size you changed it to.
If its the first, second, or third option (selectedIndex starts with the top option being 0, so when selectedIndex < 3), disable the second and third color options.

After doing that, check which color was previously selected. If you had to disable options And the second or third color was selected, set it to white.


Bruce
Bruce_KD is offline  
Old 07-06-2008, 05:37 PM   #4 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Thanks for everyones help. I will try to implement this and see what happens
slipondajimmy is offline  
Old 07-07-2008, 03:47 AM   #5 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Hey Eric,

I have another question. Is there a way to make that so it will always show 3-6 and white as the default? So the first thing someone sees in the drop down would look this

3-6 White

instead of

------ -------

Then the customer would be able to pick the other sizes and color.

The reason I want to do this is these are only available in white

<option>3-6mo</option>
<option>6-12mo</option>
<option>12-18mo</option>

The other ones are multiple colors.

Thanks again
slipondajimmy is offline  
Old 07-07-2008, 03:49 AM   #6 (permalink)
Senior Member
 
shockie's Avatar
 
Join Date: Dec 2006
Posts: 4,478
1,025.10 NP$ (Donate)

shockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond repute


Code:
<option selected>3-6mo</option>
shockie is offline  
Old 07-07-2008, 09:32 AM   #7 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Thanks Shockie I will try that out tonight
slipondajimmy is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 11:14 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85