Back
Version 1
7/13/2024
// Define the prompts
const prompts = [
"How are you today?",
"What's your favorite color?",
"Tell me a joke.",
];
// Function to generate HTML for the prompt selector
function generatePromptSelector() {
const options = prompts.map(prompt => `<option value="${prompt}">${prompt}</option>`).join("");
return `
<select id="promptSelect">
<option value="">Select a prompt...</option>
${options}
</select>
<br>
<button id="submitBtn">Submit</button>
<div id="result"></div>
`;
}
// Function to handle prompt selection
function handlePromptSelection() {
const select = document.getElementById("promptSelect");
const result = document.getElementById("result");
const selectedPrompt = select.value;
if (selectedPrompt) {
result.textContent = `Selected prompt: ${selectedPrompt}`;
} else {
result.textContent = "Please select a prompt.";
}
}
// Main function to set up the prompt selector
ap123-pinkdinosaur.web.val.run
Updated: July 13, 2024