I created a list of options using html and placed a button beneath it...I want the user to select an option and when he clicks on the button,it redirects him to a different page... Is there anyway that I can do this using JavaScript please?
Is there any way I can navigate to a link using options in html using JavaScript?
90 Views Asked by Mohammed Awal At
2
There are 2 best solutions below
0
talison Brendon
On
when you click in the button you can call a function and inside of this function you put
window.location.href = "your-url"
or you can use window.open("your-url") to open a new tab.
<select onChange="goToPage(value)">
<option disabled selected value> -- select an option -- </option>
<option value="https://google.com" > google </option>
<option value="https://stackoverflow.com" > stackOverflw </option>
<option value="https://github.com" > git </option>
</select>
<script>
function goToPage(value) {
window.location.href = value
}
</script>
you an see more in this link here
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in HTML
- How to store a date/time in sqlite (or something similar to a date)
- How to use custom font during html to pdf conversion?
- Storing the preferred font-size in localStorage
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- Is there any way to glow this bulb image like a real light bulb
- With non-graphical maps in Leaflet, zoomDelta doesn't work
- What can I do to improve my coding on both html and css
- Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
- Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
- Displaying a Movie List on a Website Using Jinja2 and Bootstrap
- How to redirect to thank you page after submitting a Google form embedded into a Google Site?
- Storing selected language in localStorage
- Fences (parenthesis, braces) in HTML and MathML
- Understanding Scroll Anchoring Behavoir
Related Questions in SEARCH
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Hospital route finding ai project
- tryin to write a function that searches for SSN in a dict, and if that SSN is found, to retrieve all the data associated with that SSN
- How the search filter from search bar works in mern?
- Angular application loading weirdly when I add "/" at the end of URL
- Elastic python to extract last 1hr tracing
- How to detect if two sentences are simmilar, not in meaning, but in syllables/words?
- I need to have a look at all my private pine scripts and filter the scripts for certain words in TRADINGVIEW
- What is correct URL? {'quandl_error': {'code': 'QECx01', 'could not recognize URL: /api/v3/databases/WIKI/search. Please check URL and try again.'}
- Solr 9 punctuation issue
- Autocomplete search filter not working for dynamically added input fields in angular
- How to correct call API search request with debounce?
- Search in GDrive only the first 5 topics
- How do I use sp/pnp sp.search to find all Associated sites when querying a hub site Id
- How to apply custom analyzers on a field in Vespa schema
Related Questions in RESPONSE.REDIRECT
- nextjs redirect of route handling not working
- When we redirect page in asp.net it seems to cache the URL and won't redirect to new URL
- Cannot redirect in Next.js 13 using res.redirect()
- Unable to redirect to external URL from Java
- return res.redirect() not working in expressJs
- Unable to set a cookie with "sameSite: none" and "secure: true" attributes while redirecting with ExpressJs
- Google redirect to a page like http://my-website.s3-website-eu-west-1.amazonaws.com/#/callback
- Secure site redirect to non secure default.aspx
- Why does a permanent redirect has cache enabled but a temporary redirect doesn't have a cache?
- dropdown selected item and repose.redirect
- How do I get my django code to redirect users accordingly
- res.redirect keeps getting called multiple times but doesnt redirect
- Visual Basic - How to open a url on a new tab of browser in ASP.NET web forms?
- ASP.NET: Response.Redirect() with root-relative URL (tilde, ~) repeats subfolder in path (after migrating from target framework 3.5 to 4.5)
- Asp.net - scroll goes to the top when redirecting querystring
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Yes,
window.location.href = "/someLocation"just is made for you.