473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Convert the option value, using textbox value

1
Hi,
Can you please help me, I want to write a dropdown box that have an option 'Other' but when the Other is selected my textbox need to be enable and take the textbox value as an output instead of Other.



[HTML]<script language=javascript type="text/javascript">
function pairSelectToOther(whichCtrl,otherCtrl,otherStr)
{
if(whichCtrl.options[whichCtrl.selectedIndex].value == otherStr)
{
otherCtrl.disabled = false;
alert("Please provide specification")
}
else
{
otherCtrl.disabled = true;
//if the guy selects some other value in the select box , after inputting into the
//other textbox, the value shouldn't get posted.
otherCtrl.value = "";
}
return true;
}
</script>

&nbsp;&nbsp;
<select id="selectlist" name="role" style="font-family: Arial; width:200px;" onChange="return pairSelectToOther(this,Reason_Other,'Other')">
<option value="Lead Arrager">Lead Arrager</option>
<option value="Joint Lead Arrager">Joint Lead Arrager</option>
<option value="Dealer">Dealer</option>
<option value="Finacial Advisor">Finacial Advisor</option>
<option value="Joint Finacial Advisor">Joint Finacial Advisor</option>
<option value="Lender">Lender</option>
<option value="Lead Manager">Lead Manager</option>
<option value="Joint Manager">Joint Manager</option>
<option value="Underwriter">Underwriter</option>
<option value="Other">Other</option>
</select>
<% //Done Role Changes (Other ) %>
<br>
<br>
<b></b><i style="font-family: Arial; color: #00376c;"><font size="2">(if <b>'Other'</b>, please specify)</font></i></b>
<br>
&nbsp;&nbsp;

<input style="font-family: Arial;" type="text" name="Reason_Other" disabled size="38">[/HTML]
Feb 19 '07 #1
2 2463
abctech
157 100+
Hi,

I tested your code, it is working,

If I'm not wrong you need that when the user selects 'Other' option from the Dropdown you want the textfield to be enabled or else not which is happening through your code.

If you want the value typed in the textfield you can get it by saying -

document.WhateverYour FormName.Reason_Other.value ;

OR

give your textfield an id and then you can access the text by using getElementById() i.e -

document.getElementById("WhateverIdOfTheTextField" ).value

Is this your requirement or something else?
Feb 19 '07 #2
acoder
16,027 Expert Mod 8TB
Hi,
Can you please help me, I want to write a dropdown box that have an option 'Other' but when the Other is selected my textbox need to be enable and take the textbox value as an output instead of Other.
There are two ways you can deal with this. One is to do all of it on the server side and don't depend on the client-side, i.e. check for 'Other', if found, instead of using the select dropdown value, use the textbox value.

The other method (which you are probably looking for) is actually quite simple. Just set the value of the 'Other' option to the textbox value. Then that will be posted to your server-side script.
Feb 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
4
by: kindermaxiz | last post by:
//I have a form such as this: echo "<form method=\"post\" action=$php_self> <BR><INPUT TYPE=\"TEXT\" NAME=\"textbox\" SIZE=\"40\"> <BR> <select name=\"searchlist\"> <option...
8
by: Assimalyst | last post by:
Hi i have a value entered into an asp text box, procedureDateTxtBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query...
12
by: DC Gringo | last post by:
How can I convert this pubLatest to a date with format "m/d/yyyy"? Dim pubLatest As New Date pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Value -- _____ DC G
5
by: manmit.walia | last post by:
Hello All, I am stuck on a conversion problem. I am trying to convert my application which is written in VB.NET to C# because the project I am working on currently is being written in C#. I tried...
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
10
by: Gary | last post by:
Hello, Anyone know how to do the following in c# - using inline codeblocks? <% If Request.Form("Name") = "Gary" Then %> <asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary,...
3
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; ...
1
by: sparksol | last post by:
I have a form with a drop down box. If you select an option in the drop down box (depending which option is selected) one or two textbox(es) and a submit button display. I would like to keep the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.