473,888 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display Textbox on the click of options of list/menu

63 New Member
Hi..There is again a similar problem..Now i;ve got the option values of list?menu box to show the textbox. If the option value of list is yes then the textbox is to be displayed . Can anyone help..through php or javascript.

ONe more thing..How can i perform the same function for more than one such kind of problem..I mean if there is any other place in the form where i have to display textbox on selecting a particular value.how can it be done..for all,the form coding is here.

[HTML] <tr>
<td class=ws_body valign=top colspan=2><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><label for="ima">Do you have a Internet Merchant Account?</label></font></td>
<td class=ws_body valign=top><fon t color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<select name=ima id =ima>
<option selected>Select </option>
<option value=imabank>Y es</option>
<option value=no>No</option>
<option value="not sure">Not Sure</option>
</select>
</font></td>
</tr>
<tr>
<td class=ws_body valign=top width="23%"><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><label for="imabank"></label>If yes, with what company <br>
(WorldPay, PaySystems, etc)?</label></font></td>
<td class=ws_body valign=center colspan=2><div align=right><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<div id="optional1" > <input maxlength=500 size=50 name=imabank></div>
</font></div></td>
</tr>[/HTML]

[HTML]<tr>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>
Will you provide the images and photos?</font></td>
<td valign=bottom> <div align=right><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<select name=imgprovide >
<option selected>Select </option>
<option value=yes>Yes</option>
<option value=no>No</option>
<option value=some>Some </option>
<option value="not sure">Not Sure</option>
</select>
</font></div></td>
</tr>
</tbody>
</table>

<table width="90%" align=center cellpadding=2>
<tbody>
<tr>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">If yes, format of the images and photos?</font></td>
<td><div align=right><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<select name=imgform>
<option selected>Select </option>
<option value="on disk">On disk</option>
<option value=broshure> Brochure</option>
<option value=paper and amp photos>Paper amp Photos</option>

<option value="dont have them yet">Don't have them yet</option>
<option value="not sure">Not sure</option>
</select>
</font></div></td>
</tr>
</tbody>
</table>
<table width="90%" align=center cellpadding=2>
<tbody>
<tr>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">Do you require your images to be scanned? font></td>
<td><div align=right><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<select name=imgscan>
<option selected>Select </option>
<option value=yes>Yes</option>
<option value=no>No</option>
<option value="not sure">Not Sure</option>
</select>
</font></div></td>
</tr>
<tr>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">If yes, how many?</font></td>
<td><div align=right><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<input maxlength=8 size=4 name=imgno>
</font></div></td>
</tr>[/HTML]
Jan 10 '08 #1
7 3500
nathj
938 Recognized Expert Contributor
Hi TechnoAtif,

The select box has an onchange event. This means that you can call the JS function I listed on your other post when the selected item is changed. Send in the correct parameters and away to go. The code would be the same as the radio buttons essentially just replace the onclick with onchange and update the parameters.

I hope this helps
nathj
Jan 10 '08 #2
TechnoAtif
63 New Member
Hi Nathj..
Thanx for your response.I am just trying your code on select box.It is working but still there are problems.:

i)As I select any of the option ,the textbox gets displayed,I want it to be displayed only on selecting first option i.e. 'yes'

ii)The text from the select box ,i.e. yes,no and nor sure get vanished as i select any of them.But i want the selected item to shown on the top in the select box. I hope you can under stand that.

So If you can,then kindly look at these problems, here is the customised code:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function toggleDisplayState(poObjectToDisplay)
  3. {                                           
  4.  
  5.     var loObject = document.getElementById(poObjectToDisplay);
  6.  
  7.     //test the current state of the object and toggle opposite state.
  8.     if (loObject.style.display != '' && loObject.style.display != 'none') 
  9.     {
  10.         loObject.style.display = 'none';
  11.     }
  12.     else 
  13.     {
  14.         loObject.style.display = 'inline';
  15.     } 
  16. }
  17.  
  18. </script>
[HTML]<table>
<tr>
<td class=ws_body valign=top colspan=2><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">Do you have a Internet Merchant Account?</font></td>
<td class=ws_body valign=top><fon t color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">

<select name=ima id=ima onChange="this. value=this.chec ked; toggleDisplaySt ate('sessionLis t')" >

<option selected>Select </option>
<option value="yes">Yes </option>
<option value="no">No</option>
<option value="notsure" >Not Sure</option>
</select>
</font></td>
</tr>
<tr>
<td class=ws_body valign=top width="18%"><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">If yes, with what company <br>
(WorldPay, PaySystems, etc)?</font></td>
<td class=ws_body valign=center colspan=2><div align=right><fo nt color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<span id="sessionList " name="sessionLi st" style="display: none;"><input type=text id=imabank maxlength=500 size=50 name=imabank></span>
</font></div></td>
</tr></table>[/HTML]

Regards
TechnoAtif
Jan 11 '08 #3
nathj
938 Recognized Expert Contributor
Hi TechnoAtif,

I will attempt to address each question in trn.

1. You only want the onChange event to fire if the user has selected 'Yes' Then I think perhaps you should adapt the JavaScript a little:
Expand|Select|Wrap|Line Numbers
  1. function toggleDisplayStateBasedOnValue(poObjectToDisplay, pcObjectToTest, pcTestValue)
  2. {                                           
  3.     lcCurrentValue = document.getElementById(pcObjectToTest).value ;
  4.     loObject = document.getElementById(pcObjectToDisplay) ;    
  5.  
  6.     //test the current value of the object and apply the correct state
  7.     if (lcCurrentValue.toLowerCase() == pcTestValue.toLowerCase())
  8.     {
  9.         loObject.style.display = 'inline';
  10.     }
  11.     else
  12.     {
  13.         loObject.style.display = 'none';
  14.     }
  15. }
  16.  
2. The trouble here is that you have an onChange handelr on the select control that sets the value :
[html]
<select name=ima id=ima onChange="this. value=this.chec ked; toggleDisplaySt ate('sessionLis t')" >
[/html]

I think the this should look more like:
[html]
<select name=ima id=ima onChange="toggl eDisplayStateBa sedOnValue('ses sionList', 'ima', 'Yes')" >
[/html]

This should prevent the value form being overwritten.

I have also added the final parameters required by the new JavaScript function and changed the name for you so that we can leave the original in tact.

I hope this helps you out
nathj
Jan 11 '08 #4
TechnoAtif
63 New Member
Hi Nathj .its working.
Thanx for that. You saved my time. You are indeed an intelligent and helpful guy.
If I have to display the list/menu box in place of textbox. then i guess the same solution could be useful with some minor customization.. Lets say if i use the same list/menu box in the place of textbox again.Then what shouuld be the right way.
What do you say..i guess you wont mind further helping me .

one more thing.

Expand|Select|Wrap|Line Numbers
  1.  if (lcCurrentValue.toLowerCase() == pcTestValue.toLowerCase())
In this line i can guess that the condition is being checked whether the selected item value is yes or not. But what does '
Expand|Select|Wrap|Line Numbers
  1. .toLowerCase() 
' signifies here.

Regards
TechnoAtif
Jan 11 '08 #5
nathj
938 Recognized Expert Contributor
Hi Nathj .its working.
Thanx for that. You saved my time. You are indeed an intelligent and helpful guy.
If I have to display the list/menu box in place of textbox. then i guess the same solution could be useful with some minor customization.. Lets say if i use the same list/menu box in the place of textbox again.Then what shouuld be the right way.
What do you say..i guess you wont mind further helping me .

Regards
TechnoAtif
Hi TechnoAtif,

Thank you for your kind words.

I am always happy to help those who, like you, have shown some attempt to help themselves first.


What you say about minor customisation is true. this basic function can be adapted as required - that's the beauty of paarameters. Remember though that if you add parameters to a function that is already in use you need to update any existing calls.

If you need any more help simply post back to the forum - I check it out every day so chances are I'll spot your post.

Cheers
nathj
Jan 11 '08 #6
TechnoAtif
63 New Member
Its ok.when i'l work on that code i will get to you in case i get caught in any mystery. For the time being thanx for being so generous.and can i have your view about the if condition and .tolowercase() method that i asked i my earlier post.

Thanx & Regards
TechnoAtif
Jan 11 '08 #7
nathj
938 Recognized Expert Contributor
Its ok.when i'l work on that code i will get to you in case i get caught in any mystery. For the time being thanx for being so generous.and can i have your view about the if condition and .tolowercase() method that i asked i my earlier post.

Thanx & Regards
TechnoAtif
Hi TechnoAtif,

Sorry, I missed that question earlier on. The .toLowerCase simply converts the string to all lowercase. this means the if condition is now case insensitive as both sides of the operator have been converted to all lower case.

Hope this helps clear it up for you.
Cheers
nathj

Ps I'm glad to have helped out, I hope your project is a success
Jan 11 '08 #8

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

Similar topics

2
3430
by: Al Sav | last post by:
Hi, I am trying to create a menu for asp.net page. The menu-detail list display, when mouse hovers over the main menu list, like you see in regular windows apps. When the detail-menu-list window displays, it goes 'behind' combo box (sent to back). For other controls, like textbox, it is fine. Can some explain, how can I send the list box (<asp:listbox>) to become the underneath and not display on top? Alwin S.
2
22025
by: Pete | last post by:
I have some funky form/event behavior. Access 97. Split frontend/backend, using Access security. I have the same behavior (or lack of behavior) for the pag_Click() event of two separate pages on different menu forms. Details: frmTRNMenu is the main menu of the application. It uses tabbed pages to logically separate menu items. The last tab on the list is different - it has an image and then "O&M". Clicking on this last page will...
4
1647
by: jsd219 | last post by:
I am a newbie for sure; problem, I have a page that has dynamically generated sections at the top, when I click on one of the sections I would like the list of categories associated with the section to display in my left navigation; If I click a different section the current navigation list would be replaced by the categories associated with the new section I clicked on and so on.
1
2331
by: Bobc003 | last post by:
Hi, I'd like to put a double drop-down menu on my webpage and instead of a redirection to a new webpage, I'd like to display the result in a new section. I'm kind of stuck and I only have a triple menu here. Here an exemple of what I need. (menu)Size, (menu) color and then display the price somewhere in a box. Thanks a bunch Bob
5
1834
by: bissatch | last post by:
Hi, I ocasionally use display: none; to hide divs that, on the click of a link they will reappear. For example, maybe I create a menu and when you click a link of menu options the submenu options appear. When I used this attribute, would search engines ignore indexing the hidden submenu links because it doesnt initially appear on the screen. Im a bit concerned that my links wont be followed through during indexing (and theres many of...
0
3582
by: rehanmomin | last post by:
Just to start off, I am writing a web application using C#. I have a Menu which is binded to an XML datasource. There are three menu items each with submenus and a textbox where I want to display the value of the selected menu item. Heres the XML datasource that I am using: <?xml version="1.0" encoding="utf-8" ?> <Home> <Menu text="Patient" description=" "> <SubMenu text="First Name" description="firstName"></SubMenu> ...
2
3278
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully validated my HTML and CSS code. 1. When I clear cache and refresh my webpage, it takes 3 tries before the popup window displays - I click on the button once, a white window the size of my webpage displays. I close it and click on the button again (for...
3
2103
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a webform with several entry boxes and the user enters numbers in each box. I keep a running total (just adds all of the entries together) but am posting back to the server to do this. Is there any way to do it all on the client side, without posting back to the server? I would like to update the running total each time the user inputs an amount in a textbox and then goes to the next textbox. Thanks, -- Paul G Software...
0
9800
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10777
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10882
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10438
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7990
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3251
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.