On a feature phone with Opera Mini, can choosing a file to upload trigger a UI change without javascript?

696 Views Asked by At

I'm not sure I'm going to ask this the right way. I am developing for feature phones for the first time, e.g. users with limited bandwidth running Opera Mini and no javascript.

I have a form with a text box and an optional photo uploader. Most people do not upload a photo. I would like to achieve the following behavior: if the user chooses a file from the phone to be submitted in the form, the submit button text changes from "Submit" to "Submit with Photo". Is this possible without javascript?

1

There are 1 best solutions below

0
On

With out javascript answer is no. And my answer is no and with javascript.

Let me explain.

About javascript in Opera Mini.

Javascript is not disabled in Opera Mini. You can use it. Opera Mini supports XMLHttpRequest, querySelector/querySeletorAll, for example. Opera Mini has a Presto javascript engine on its servers which was using on desktop Opera, but with out CSS3 features which a expensive on rendering for browser.

About forms and it elements.

Opera Mini supports change event for select elements only. And then you change select Opera Mini re-render the page by reloading it with changed select value from Opera Mini server.

Example:

HTML:

<form action="">
    <select>
        <option>Change me</option>
        <option>Im changed</option>
    </select><br>
    <input type="file" id="file-control"><br>
    <input type="submit" value="Submit" id="submit-control">
</form>

Javascript:

var submitNode = document.getElementById('submit-control');

document.getElementById('file-control').addEventListener('change', function () {
    //this will not fire in Opera Mini
    if (this.files[0]) {
        submitNode.value = 'Submit with photo';
    } else {
        submitNode.value = 'Submit';
    }
});

document.querySelector('select').addEventListener('change', function () {
    //this will work in Opera Mini and call after Opera Mini get changed page from Opera Mini server
    alert('Select was changed');
});

Read this to know what Opera Mini can:

  1. Opera Mini and Javascript
  2. FAQ of Opera Mini. It's very useful.
  3. Opera Mini and OBML