Jump to content

animockery

Recommended Posts

OK, I have hit a snag and I want to try and make this work if I can. I am trying to add a new text field next to a current list field based on a single selected item. can anyone help me on this? I added the segments that I want this to change. *script* function DbRole(myform){if (document.myform.Accesslevel1.value=="Database Role = "){document.myform.Accesslevel1("DbRole1").setValue(""); AddFields();}} *form* <input name="Accessgroups1" type="text" size="50"> <select name="Accesslevel1"> <option value=""></option> <option value="Read">Read</option> <option value="Write">Write</option> <option value="Read/Write">Read/Write</option> <option value="Update">Update (accounting)</option> <option value="Delete">Delete (Accounting)</option> <option value="Update/Delete (Accounting)">Update/Delete (Accounting)</option> <option onChange="DbRole()" value="Database Role = ">-Database Role-</option> (**the idea is that when this last item is selected a text field will appear next to this list field**) </select> Any help would be appreciated, I am new to this but I have already managed to set up other js that works but this one escapes me at this moment.

Link to comment
Share on other sites

OK so I put the onchange in my select but I am not sure how I check the value of the selected option. <select name="Accesslevel1" onChange="DbRole(Accesslevel1.value);"> the if condition should only be when "Database Role" is selected. I also am not sure if I did the "addfeilds()" part right.

Link to comment
Share on other sites

No. There's no variable called "Accesslevel1"You have to pass a reference to the element in the function.

<select name="Accesslevel1" onChange="DbRole(this);">

function DbRole(el) {    var value = el.options[el.selectedIndex].value;    if(value == "Database Role = ") {	    // There is no document.myform, this is non-standard and shouldn't be used	    // Use getElementById() or getElementsByTagName()	       }}

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...