Concealing the submit button until a file has been selected

How can I make the submit button invisible until a file is selected?

<form action="upload.php" method="POST" enctype="multipart/form-data">
     <input type="file" name="imageURL[]" id="imageURL" />

     <input type="submit" value="submit" name="submit" style="display: none;" id="submitButton"/>
</form>

Answer №1

To start, you can initially hide the submit button and then display it upon a change in the input type file.

Here is an example of how you can achieve this:

$("#imageURL").on("change", function(){
    $("#submit").show();  
})

I have created a JSFiddle using jQuery to demonstrate this.

I trust that this solution will be beneficial.

Answer №2

This solution offers a more efficient approach:

$('[type=submit]').hide();

setInterval(function(){
    if($('#imageURL').val()!=""){
     $('[type=submit]').show();
    }else{
        $('[type=submit]').hide();
    }
},1000);

To see a demonstration, click on this link: http://jsfiddle.net/s24ZW/14/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why isn't the background-image displaying with the use of the url() function?

I've been attempting to set an image as the background using background-img:url(imageLing), but it's not working properly. When I inspect the element, it shows me background-image: url(assets/backgrounds/5.jpg);. What could be causing this issue? ...

Addressing responsiveness problems with Bootstrap navigation bar

Seeking assistance with setting up the fundamental bootstrap grid system. Despite my efforts, I am unable to make it work. Could someone guide me in creating the basic structure for the Navbar above? Specifically, focusing on using columns and rows with p ...

Adjust the background color of a list item using Typescript

At the top of my page, there's a question followed by a list of answers and the option to add new ones. You can see an example in the image below. https://i.stack.imgur.com/NPVh7.jpg The format for each answer is "(username)'s response: at this ...

js The correct value is not being set to the div's style.top

function gamestart(){ var gr; var gr = true; console.log(gr==true); if(gr == true){ console.log("we have activated pointer key detection dear Mr.ketsebaot") document.onkeydown = checkk; } } function checkk(e){ cons ...

Combining arrays using JavaScript

I'm struggling to enhance the following code - it looks a bit messy: Here is my data format: date d1 d2 d3 d4 d5 d6 110522 5 1 3 5 0 7 110523 9 2 4 6 5 9 110524 0 0 0 0 1 0 110525 0 0 3 0 4 0 ... I am importing data from a text file using d3.j ...

Limit the application of the map() function to a single column within a 2-dimensional array in JavaScript when using Find and Replace

I have been using Google Sheets for my work Recently, I came across a find and replace function that I found here. This function works perfectly when the array is generated from a single column of data. However, there are certain cases where I need to us ...

Using Google fonts offline: a step-by-step guide

Is it possible to download Google fonts and link them offline for a localhost webpage? ...

Dividing a JSON array by a specific key using lodash underscore

I'm on a quest to extract the distinct items in every column of a JSON array. Here is what I aim to convert : var items = [ {"name": "Type 1","id": 13}, {"name": "Type 2","id": 14}, {"name": "Type 3","id": 14}, {"name": "Type 3","id": 13}, {"na ...

Two separate Bootstrap dropdowns are failing to function independently from each other

Can anyone help me prevent both buttons from displaying a drop-down when only one is clicked? https://i.stack.imgur.com/nvtbm.png Below is my HTML code: <form action="{{ url_for('crudSEapi.gcp_image_search') }}" method="post&q ...

Overridden CSS rules

Having a slight CSS dilemma. Within my webpage's html, I have the following structure: <div class='box-div'> <div>Entry 1</div> <div class='hide'>Entry 2</div> </div> Here is my associated ...

The complete guide to effectively concealing double arrows within a Bootstrap 4 custom-select component

If you're looking to hide the double arrow on the right of the bootstrap 4 custom-select field, there have been solutions provided here. However, even after implementing those changes, the text on the right-hand side still gets obscured by the opaque ...

Is there a way to export static HTML from Next.js to different directories at once?

My Next.js website is static with 1 million pages, but I am facing an issue where all the exported pages are stored in the same folder, requiring a lot of RAM to access files. Is there a way to export pages into multiple folders, maybe grouping 100k pages ...

Form tag definitions are missing on the login page

Here is a snippet of code I am using: <%= form_tag :action => 'process_login'%> Username: <%= text_field "user", "fullname" %>&#x00A; Password: <%= password_field "user", "password" %>&#x00A; <%= submit_t ...

Responsive Grid with Card component using React Material UI

Struggling to devise a responsive grid layout with same height cards featuring images in a React and Material-UI setup. After hours of tinkering, the "flex" part is proving to be quite puzzling. Seeking guidance. The code snippet in question: const useSt ...

Using the ng-show directive in AngularJS allows you to pass elements in

Web Development <li ng-show="sample($event)" TestLi</li> JavaScript Functionality $scope.sample = function($event){ //$event is undefined //perform some action } I have experimented with passing the HTML element using ng-click, but I am curio ...

Is there a way to enable previous days in a UI datepicker after switching to a different month?

A different question can be found at: How can I modify the UI datepicker after switching months? In contrast to Nick Craver's solution, I encountered a separate issue: While Nick Craver sourced his dates from the js variable xml, my dates are retr ...

Controller fails to initialize when utilizing $location.path or $state.go

Issue with Controller Initialization after Redirect in Ionic App I have encountered an issue where the controller is not initializing on the same page when I use $state.go or $location.href. In my Ionic app, I am using a sidemenu to pass category Id to th ...

Semi-transparent image

Can I achieve a semi-transparent image? Similar to this gradient: background:linear-gradient(to bottom,rgb(44, 44, 44),rgb(29, 38, 51,0.322)); ...

The website is not optimized for mobile viewing

I have recently made an existing website responsive using Twitter Bootstrap. Everything seemed to work fine when I tested it by resizing the browser window, as it perfectly fit in the viewport. However, upon checking the site on mobile and tablet devices, ...

Pass the array data stored in React state over to Node/Express

I have been exploring ways to transfer an array from my react front end to my node/express back end. Initially, I attempted the following method. In React: saveUpdates = (clickEvent) => { var list = []; var length = this.props.title.length; ...