BoDiE2003
BoDiE2003

Reputation: 1359

Javascript: Enabled / Disable radio on selected with javascript

I would like to make this form dynamic with prototype. I mean, the radio should be disabled, but when you chose one, with js, it should turn them enabled, same way if you chose the other one, the 1st should turn disabled.

This is my HTML, but I have no idea where to start with JS to make this work, thank you

<form id="uploadForm" method="post" action="/parser/parseCurriculumVitae.do" enctype="multipart/form-data">
<fieldset>
        <div id="uploadCv">
                <input type="radio" id="uploadCvSelector" name="uploadFormSelector"/>
                <input disabled type="file" id="uploadCv" name="uploadCv" />
        </div>
        <div id="pastedCv">
                <input type="radio" id="pastedCvSelector" name="uploadFormSelector" />
                <textarea disabled id="pastedCv" name="pastedCv" rows="8" cols="40" onclick="this.value=''">Paste your Cv Here</textarea>
        </div>
<input type="submit" value="Send'em!"/>
</fieldset>
</form>

Upvotes: 0

Views: 2531

Answers (1)

SpliFF
SpliFF

Reputation: 38966

i think your request to use prototype prejudices the answer. you can do this just fine without a library.

<input type="radio" id="pastedCvSelector" name="uploadFormSelector" onclick="document.getElementById('pastedCv').disabled=false;document.getElementById('uploadCv').disabled=true;">
<textarea disabled id="pastedCv" name="pastedCv" rows="8" cols="40" onclick="this.value=''">Paste your Cv Here</textarea>

UPDATED (again)

Upvotes: 2

Related Questions