screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; // Child Component const Dropdown = () => { const handleDropdownChange = (e) => { const selectedValue = e.target.value; window.open(selectedValue, '_blank'); // Open the selected URL in a new tab }; return ( <div> <h2>Select a value:</h2> <select onChange={handleDropdownChange}> <option value="https://fontawesomeicons.com">Font Awesome Icons </option> <option value="https://tutorialsplane.com">Tutorials Plane </option> <option value="https://sarkarinaukriexams.com">Sarkari Naukri Exams </option> </select> </div> ); }; // Parent Component const App = () => { return ( <div className='container'> <h1>React URL Based on Dropdown</h1> <Dropdown /> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> /* Styles for the container and button */ .container { max-width: 800px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; } /* Styling for the select element */ select, input[type="email"], input[type="tel"] { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; outline: none; } /* Styling for the option elements */ .container option { font-size: 16px; } label { display: block; margin-bottom: 10px; } </style> </body> </html>