Plzz someone tell me what's the problem in my code below ...as the first function(changeME ) is working BUT THE 2ND function (inputName ) is not working....is there some problem with the variables?? As m New in asp.net plzz help me out with some basic concept which I might be missing.
`PROJECT
<input type="radio" name="portal" id="radio1" onclick="changeMe(this);"/> <input type="text" name="textprojectOff" id="text1" value="Project Name" onclick="changeMe(this);"/>
<script type="text/javascript" >
function changeMe(inField) {
var fieldId = inField.id;
var type = fieldId.substring(0, 4);
if (type == 'text') {
var name = fieldId.substring(4);
var radioButton = document.getElementById("radio" + name);
radioButton.checked = true;
} else {
var name = fieldId.substring(5);
var textField = document.getElementById("text" + name);
textField.focus();
}
}
</script>
NON-PROJECT<input type="radio" id="radio2" name="portal" onclick="inputName(this)"/> <input type="text" name="textnonprojectOff" id="text2" value="Departement" onclick="inputName(this);"/>
<script type="text/javascript">
function inputName(inDepartment){
var departmentId=inDepartment.id;
var type= departmentId.substring(0,4);
if (type== 'text'){
var name= inDepartment.substring(4);
var radioButton=document.getElementById("radio"+ name);
radioButton.checked=true;
}
else{
var name=inDepartment.substring(5);
var textfield=document.getElementById("text"+name);
textfield.focus();
}
</script>
protected void RadioButton2_Checked(object sender, EventArgs e) { if (RadioButton2.Checked) { TextBox11.Visible = true; } else { TextBox11.Visible = false; TextBox11.Text = string.Empty; } } protected void RadioButton3_Checked(object sender, EventArgs e) { if (RadioButton3.Checked) { TextBox12.Visible = true; } else { TextBox12.Visible = false; TextBox12.Text = string.Empty; } }
Anyone can plzzz modify this code according to my previous requirement as my AIM is Same as previous but now I m using codebehind for it...but its not working properly..
plz chk out the fiddle given in the previous answers and kindly modify this code accordingly.
Check this Fiddle
function inputName(inDepartment){
var departmentId=inDepartment.id;
var type= departmentId.substring(0,4);
if (type== 'text'){
var name= departmentId.substring(4);
var radioButton=document.getElementById("radio"+ name);
radioButton.checked=true;
}
else{
var name=departmentId.substring(5);
var textfield=document.getElementById("text"+name);
textfield.focus();
}
}
var name= departmentId.substring(4);
and not var name= inDepartment.substring(4);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.