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 8226189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:40:48+00:00 2026-06-07T15:40:48+00:00

I have a list of widths in a dropdown box. They are dynamic because

  • 0

I have a list of widths in a dropdown box. They are dynamic because each product has different widths so I’ve setup the code to look for the minimum and maximum. Then it sets up a dropdown list in increments of 1″.

Next to the width are 1/8″ increments. So for example you could pick 52 1/8.

If the maximum width is 92 inches let’s say, the 1/8 increment dropdown box should disappear or disable because since 92 is max.. you can’t pick 92 1/8.

How do I make that 1/8ths box disappear or disable? Here is part of my current code for the dropdown box.

<select name="width_str" id="width_str" onchange="doCalc();" style="width:50px;">
<option value="">--</option>
<?php
$counter = $minwidthRS - 1;
$start = $minwidthRS;

for($start; $start < $maxwidthRS + 1; $start++) {
$counter = $counter + 1;
echo "<option value=".$counter.">".$counter."</option>";
}
?>
</select>

Code for the select dropdown box with 1/8ths that I would like to disable or disappear when MAXIMUM above is selected.

<select name="widthfrac_str" id="widthfrac_str" onchange="doCalc();" style="width:50px;">
<option value="">--</option>
<option value="1/8">1/8</option>
<option value="1/4">1/4</option>    
<option value="3/8">3/8</option>
<option value="1/2">1/2</option>    
<option value="5/8">5/8</option>
<option value="3/4">3/4</option>    
<option value="7/8">7/8</option>
</select>

I’m aware of how to send a selected width value over to a PHP page using AJAX and compare it there, but what do I send back in the success callback? Could I send something that tells the container of that 1/8 measurement dropdown to disable or disappear?

Many thanks! If you need more code let me know. The doCalc() script basically uses AJAX and sends the width to php processing page in order to update price instantly.

EDIT (added more code):

Here is part of my script..

<script type="text/javascript">
function doCalc(){
var roomX = $('#room_str').val();
... lots of variables set here

$.post('db_query.php',
{roomX:roomX, etc. etc. etc.}, 
function(data) {
data = $.parseJSON(data);
$('#roomname-placeholder').html(data.roomname);
// ... lots of placeholders and code here
});
return false;
};
</script>   

Not sure if it helps but I learned a little about using a callback to alter an input field and replacing its value with this: $('input[name=x_login]').val(data.loginid);

It would be great if there was code like that to simply change the other dropdown box disabled=disabled? Does that make sense? I’m still learning programming lingo!

  • 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-07T15:40:50+00:00Added an answer on June 7, 2026 at 3:40 pm

    You can call another function with onchange(), which should check the number chosen for the first value. If it is the maximum, then toggle function to hide the second element. A neater solution would be to include the ‘check for maximum value and toggle if true’ inside doCalc.

    Remember to make PHP check also the value, since if user chooses the second value AND then the maximum for the first block, it should hide the second one, but it’s value might still be sent.

    EDIT:

    <script type="text/javascript">
    function doCalc(){
    var roomX = $('#room_str').val();
    if (roomX == <?php echo $maxwidthRS; ?>)
      {
      document.getElementById('widthfrac_str').style.display = 'none';
      // You also need to make the second element's value 0 within those brackets
      }
    ... lots of variables set here
    
    $.post('db_query.php',
    {roomX:roomX, etc. etc. etc.}, 
    function(data) {
    data = $.parseJSON(data);
    $('#roomname-placeholder').html(data.roomname);
    // ... lots of placeholders and code here
    });
    return false;
    };
    </script>
    

    There’s no problem putting php within javascript if it’s in a .php file. It worked as the OP stated in the comments, great!

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

Sidebar

Related Questions

I have a dropdown list box that displays data from my database. Problem is
I have a dropdown menu which at at the minute has a different coloured
I have a dropdown menu which at at the minute has a different coloured
i have list of images and on mouse over there is option box shows
I have a question about divs and frames. When you have a dropdown list
I have a user control, a dropdown list, that's comprised of many component controls.
I have an options button that, when clicked on, will display a dropdown list
I have a dropdown list populated by mysql working perfectly, I also have it
I have a asp.net dropdown list that populates from a sqldatasource. My issue is
Is it possible to set the width of a spinner dropdown list in code?

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.