• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

267
Views
Select tag, setting option over a certain max value

I'm trying to add an option to my select element to be able to choose an max option over a certain value. In this case 250. I've tried to do the greater than ">" comparison operator >250 but it doesn't seem to accept that syntax. How would one max it possible to do so?

import { useState } from "react";
import "./styles.css";

export default function App() {
  const [minPrice, setMinPrice] = useState(0);
  const [maxPrice, setMaxPrice] = useState(50);

  const handlePrice = (value) => {
    switch (value) {
      case "1":
        setMinPrice(0);
        setMaxPrice(50);
        break;
      case "2":
        setMinPrice(50);
        setMaxPrice(100);
        break;
      case "3":
        setMinPrice(100);
        setMaxPrice(250);
        break;
      case "4":
        setMinPrice(250);
        setMaxPrice(>250); //doesn't work
        break;
      default:
        setMinPrice(0);
        setMaxPrice(50);
        break;
    }
  };

  return (
    <div className="App">
      <select
        className="custom-select"
        id="priceGroup"
        onChange={(event) => handlePrice(event.target.value)}
      >
        <option value="1">Under $50</option>
        <option value="2">$50 to $100</option>
        <option value="3">$100 to $250</option>
        <option value="4">Over $250</option>
      </select>

      <div>Your min price is {minPrice}</div>
      <div>Your max price is {maxPrice}</div>
    </div>
  );
}
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What I can understand from the question is that you want to display ">250" when user selects option 4. If so, setMaxPrice(>250) will not work because >250 it doesn't come under any datatype. You could pass it down as a string like setMaxPrice(">250") and that should work.

about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error