473,804 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Toggle 2 forms with radio button

7 New Member
Hi all,

First here is the website of what I am trying to do: http://www.exmhosting. com/

Locate the login form on the top-right of the page. What I need to do is allow the user to sign into different sections of the website according to the radio button choice at login.

If the user chooses Webmail then they input their email address and password and login. If the user chooses clients they input their username and password and login.

My idea was to create 2 forms, 1 for webmail and 1 for clients and when they select a radio button the correct form is shown. If they select the other radio button the wrong form is hidden and the correct form made visible.

As you can also see I need to make this form horizontal and one 1 line, see website for example. The input box for the webmail will also need to be longer as the user inputs a full email address instead of a smaller username.

This needs to works obviously in IE as well as FF.

Thanks for any help.
Sep 24 '08 #1
4 2052
Atli
5,058 Recognized Expert Expert
Hi.

You could simply change the action property of the <form> element using the radio button's onclick event.

You could even set the width of the name text box to like that.
Sep 24 '08 #2
makunta
7 New Member
Hi.

You could simply change the action property of the <form> element using the radio button's onclick event.

You could even set the width of the name text box to like that.
This sounds like a good idea to me. Can you give me a few tips on how I might do this. Obviosly I will use a function to do the changes but am not quite sure how.

This is what I have come up with so far and need some help with the bits in CAPITAL letters.

Expand|Select|Wrap|Line Numbers
  1. <form name='login' method='post' ACTION=''>
  2.   <label>webmail</label>
  3.   <input name='login' type='radio' value='webmail' ONCLICK='<? changeformsetting("webmail"); ?>' />
  4.   <label>clients</label>
  5.   <input name='login' type='radio' value='clients' checked='checked' ONCLICK='<? changeformsetting("clients"); ?>' />
  6.   <input type='text' name='user' id='loginUsername' SIZE='' VALUE='' />
  7.   <input type='password' name='pass' id='loginPassword' value='password' />
  8.   <input type='submit' value='Login' id='loginSubmit' />
  9. </form>
  10.  
  11. <script language="javascript"> 
  12. function changeformsetting(logintype) {
  13.   if ($logintype == "webmail") {
  14.     ACTION = "https://someurl.com";
  15.     SIZE = 20;
  16.     VALUE = "email address"; 
  17.   }
  18.   else {
  19.     ACTION = "/login.php";
  20.     SIZE = 10;
  21.     VALUE = "username"; 
  22.   }
  23. }
  24. </script> 
  25.  
Once again thanks for any help offered.
Sep 26 '08 #3
makunta
7 New Member
Well I have worked it out and will put my solution here for anyone else who may be in a similar dilemma.

This is the from I used:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <form name='login' id='loginform' method=post action='/logmein.php'>
  3.   <input name='login' type='radio' value='webmail' OnClick=\"changeformsetting('webmail','loginUsername','loginform');\" id='webmail' /><label>WEBMAIL</label>&nbsp;
  4.   <input name='login' type='radio' value='clients' OnClick=\"changeformsetting('clients','loginUsername','loginform');\" id='clients' checked='checked' /><label>CLIENTS</label>&nbsp;&nbsp;&nbsp;&nbsp;
  5.   <input type='text' name='user' id='loginUsername' value='username' size='20' />
  6.   <input type='password' name='pass' id='loginPassword' value='password' size='20' />";
  7.   <input type='submit' value='Login' id='loginSubmit' />
  8. </form>
  9.  
and this is the function I created to do the work:
Expand|Select|Wrap|Line Numbers
  1. function changeformsetting(id1,id2,id3) {
  2.   var el1 = id1; //radio button
  3.   var el2 = id2; //text input
  4.   var el3 = id3; //form
  5.   if (document.getElementById(el1).value == 'webmail') {
  6.     document.getElementById(el2).size = 30;
  7.     document.getElementById(el2).value = 'email address';
  8.     document.getElementById(el3).action = 'https://someurl/login/';
  9.   }
  10.   if (document.getElementById(el1).value == 'clients') {
  11.     document.getElementById(el2).size = 10;
  12.     document.getElementById(el2).value = 'username';
  13.     document.getElementById(el3).action = '/logmein.php';    
  14.   }
  15. }
  16.  
I know there are probably prettier ways of doing this but at least this works thanks to the advice of Atli.
Sep 26 '08 #4
Atli
5,058 Recognized Expert Expert
Glad you found a solution!
And thank you for sharing it.
Sep 26 '08 #5

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

Similar topics

2
2631
by: newfie912 | last post by:
I have an online application used for grading students. On one of the pages, I have a table with two rows and each row has 16 cells. The upper row contains the letter grade (A, A-, B+, B, etc) and the lower row has a 16 radio buttons for selecting the appropriate grade. This all writes to a SQL server back-end and has been working fine for several semesters. Some faculty members have complained that it is hard to read and see which...
4
3093
by: Z.K. | last post by:
I started a forms application and I put on the form three buttons. In the functions for the radio buttons I put in a single messagebox like: MessageBox("Hello 1") MessageBox("Hello 2") MessageBox("Hello 3")
1
4443
by: Jeffrey Christiansen | last post by:
I wanted to add a toggle button to a VB2005 form to be used for a simple Windows Application (i.e. compiled to a "*.exe"), so I added the ActiveX Microsoft Forms Object toggle button, however I can't get this button does work properly. The documentation I found in the FM20.CHM files says the button state can be determined from its "Value" property, but the property list shown in VB2005 does not have a "Value" property. How is the button...
8
11759
by: Jeff Ciaccio | last post by:
I would like to create a toggle button, so I chose a radio and set its apperance to button. Is seems my method always makes this .checked = false. Can somebody help me to see the error in my ways? I'm guessing that I just need an event that triggers before it actually changes the value of the button. Private Sub radSound_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radSound.Click If radSound.Checked = True...
0
9582
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
10580
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
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
10082
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
9157
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...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
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.