mooby1231 Posted July 7, 2014 Share Posted July 7, 2014 I am trying to use an onclick or onchange inline event to trigger a change the input type in my html form, I have been researching this for quite some time, but can't figure it out. I could really use some help. I think it will work if I can trigger the event based on the clients radio button selection. <form name="selectiontype"> <input type="radio" name="selecttype" Value="one" />selection1 <input type="radio" name="selecttype" Value="one" />selection2 <input type="radio" name="selecttype" Value="one" />selection3 <input type="radio" name="selecttype" Value="three" />selection4 <p>Please enter your type selection</p> <input type="text" name="myElement" id="myElement" /> <script> var i = 5; var x = 6; if (selecttype = three) {{ for (i = 5; i < 12; i++) { myElement.getElementById('myElement').type = 'password';}} if (selecttype = one) {{ for (x = 6; x < 13; x++) { myElement.getElementById('myElement').type = 'password';}} var i = 11; var x = 12; if (selecttype = three) {{ for (i=11; i < 16; i++) { myElement.getElementById('myElement').type = 'text';}} if (selecttype = one) {{ for (x=12; x < 17; x++) { myElement.getElementById('myElement').type = 'text';}} </script> <input type="Submit" value="done" /> </form> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 7, 2014 Share Posted July 7, 2014 You can put a click event on those radio buttons. Right now all of that Javascript code only runs once, as soon as it displays the form. It's not inside an event handler. Link to comment Share on other sites More sharing options...
davej Posted July 7, 2014 Share Posted July 7, 2014 I am trying to use an onclick or onchange inline event to trigger a change the input type in my html form... Where is this "onclick or onchange inline event" that you say you are using? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now