Jump to content

Very Simple Question! Help!!!


TheFilmGod

Recommended Posts

I'm new to javascript. I have never used it before. This is a special ocassion! 8) 8) 8)

 

<script type="text/javascript">

document.write_story.picaltinput.disabled;
document.write_story.picuploadinput.disabled;

</script>

 

This is at the head of my document. I want javascript to go to those input fields and add disabled="true". At this time, the disabled feature has not been put in the code. So no "disabled" or "disabled=false" exist!

 

I want this to work like this: When you have javascript turned off, the inputs are not disabled. But when it is on, I want them disabled unless they click on the radio buttons. The buttons work just fine. I just can't get the first step to work.

 

Summary: NO JAVASCRIPT = not disabled input field

 

Javascript on = disables input field

 

 

This is all I want it to do. What I am doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/62313-very-simple-question-help/
Share on other sites

here you go

<form id="myform">
<fieldset>
enable input:<input type="radio" onclick="changeInputStatus(this.value)" name="inputStatus" value="false" />
disable input:<input type="radio" onclick="changeInputStatus(this.value)" name="inputStatus" value="true" />
</fieldset>
<input type="text" name="text1" />
</form>
<script>
//this variable refers to the input box now
var element=document.getElementById('myform').text1;

function changeInputStatus(setDisabled){
setDisabled=eval(setDisabled);
if(setDisabled==true){
	element.disabled="disabled";
}
else{
	element.disabled="";
}
}
//disables the input
changeInputStatus(true);
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.