| | |
regarding drpo down list
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 37
Reputation:
Solved Threads: 0
Hi SheSaidImaPregy,
Thanks for your reply but i am not able to understand the logic behind the code for "focus()" method. What u said is correct i am getting an error with the following code
Help please
Thank u.
Thanks for your reply but i am not able to understand the logic behind the code for "focus()" method. What u said is correct i am getting an error with the following code
ASP.NET Syntax (Toggle Plain Text)
<script type="text/javascript"> function chkChange(ddl) { var textbox = document.getElementById("<%= txtdept.ClientID %>"); if (ddl.options[ddl.selectedIndex].value == "New Department") { textbox.style.display = "block"; } else { textbox.style.display = "none"; } document.getElementById("<%= ddldept.ClientID %>").options.add(new Option(index, "value", "text")); } </script>
Help please
Thank u.
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
I'm sorry, didn't realize that was a function I built to add an option. Here is the way to add an option:
This will add an option to the dropdownlist everytime the textbox loses focus, as long as the value is empty and isn't only spaces.
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> function chkChange(ddl) { var textbox = document.getElementById("<%= txtdept.ClientID %>"); if (ddl.options[ddl.selectedIndex].value == "New Department") { elm.onblur = function() { addOptionOnBlur(this); }; textbox.style.display = "block"; textbox.focus(); } else { textbox.style.display = "none"; } } function addOptionOnBlur(elm) { if (elm.value.length > 0 && elm.value.replace(/ /g, "").length > 0) { document.getElementById("<%= ddldept.ClientID %>").options.add(newOption(elm.value, elm.value)); } } function newOption(val, txt) { var option = document.createElement("OPTION"); option.text = txt; option.value = val; return option; } </script>
This will add an option to the dropdownlist everytime the textbox loses focus, as long as the value is empty and isn't only spaces.
I answer pm's.
I answer questions.
I answer quickly.
I answer.
I answer questions.
I answer quickly.
I answer.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: How to get an excel file while button click.
- Next Thread: Custom class object question
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






