trunder
11-11-2010, 06:43 PM
Hi!
I have two input fields from who one of them i to upload image and other text field to upload image from url .I want to disable one of this fileds and to stay only one .For js code is helping me one friend but him help was enough and the code have some bugs,like fist fileds as active and them when check one has disable and opposite.I want this nly one field to be disable when the page is load but when checkbox is clicked .Sorry for my english .I hope you understand me.
<script type="text/javascript">
window.onload = function(){
var check = document.getElementById('check1');
var file = document.getElementById('file');
var text = document.getElementById('text');
check . onchange = function(){
if( check.checked ){
text.setAttribute('disabled', 'disabled');
file.removeAttribute('disabled');
}
else{
text.removeAttribute('disabled');
file.setAttribute('disabled', 'disabled');
}
};
};
</script>
<input id="check1" type="checkbox" name="check" /> From link!!!<br/>
Poster:<input id="file" type="file" name="poster" />
Poster from link:<input id="text" type="text" name="postlink" /><br/>
I have two input fields from who one of them i to upload image and other text field to upload image from url .I want to disable one of this fileds and to stay only one .For js code is helping me one friend but him help was enough and the code have some bugs,like fist fileds as active and them when check one has disable and opposite.I want this nly one field to be disable when the page is load but when checkbox is clicked .Sorry for my english .I hope you understand me.
<script type="text/javascript">
window.onload = function(){
var check = document.getElementById('check1');
var file = document.getElementById('file');
var text = document.getElementById('text');
check . onchange = function(){
if( check.checked ){
text.setAttribute('disabled', 'disabled');
file.removeAttribute('disabled');
}
else{
text.removeAttribute('disabled');
file.setAttribute('disabled', 'disabled');
}
};
};
</script>
<input id="check1" type="checkbox" name="check" /> From link!!!<br/>
Poster:<input id="file" type="file" name="poster" />
Poster from link:<input id="text" type="text" name="postlink" /><br/>