33 lines
933 B
JavaScript
33 lines
933 B
JavaScript
|
|
import Button from '@mui/joy/Button';
|
||
|
|
import Select from '@mui/joy/Select';
|
||
|
|
import Option from '@mui/joy/Option';
|
||
|
|
import Stack from '@mui/joy/Stack';
|
||
|
|
|
||
|
|
export default function SelectFormSubmission() {
|
||
|
|
return (
|
||
|
|
<form
|
||
|
|
onSubmit={(event) => {
|
||
|
|
event.preventDefault();
|
||
|
|
const formData = new FormData(event.currentTarget);
|
||
|
|
const formJson = Object.fromEntries(formData.entries());
|
||
|
|
alert(JSON.stringify(formJson));
|
||
|
|
}}
|
||
|
|
>
|
||
|
|
<Stack spacing={2} sx={{ alignItems: 'flex-start' }}>
|
||
|
|
<Select
|
||
|
|
placeholder="Select a pet"
|
||
|
|
name="foo"
|
||
|
|
required
|
||
|
|
sx={{ minWidth: 200 }}
|
||
|
|
>
|
||
|
|
<Option value="dog">Dog</Option>
|
||
|
|
<Option value="cat">Cat</Option>
|
||
|
|
<Option value="fish">Fish</Option>
|
||
|
|
<Option value="bird">Bird</Option>
|
||
|
|
</Select>
|
||
|
|
<Button type="submit">Submit</Button>
|
||
|
|
</Stack>
|
||
|
|
</form>
|
||
|
|
);
|
||
|
|
}
|