Question

How to dynamically change forms via a combo box (Javascript, DHTML, HTML, PHP?)

Asked by: GamerXLT

I am trying to produce an effect for my page where there is a combo box and the user selects an option. After selecting the option, the form/page dynamically updates without refreshing the window/page. At first I assumed this is done with frames, but after further examiniation I'm starting to think it's something different. Listed below are a few examples to give you an idea of what I want to reproduce/emulate:

1.) https://signup.live.com/hmnewuser.aspx?mkt=EN-CA&ru=http%3A//login.live.com/login.srf%3Fid%3D2%26ru%3Dhttp%253a%252f%252fwww.hotmail.msn.com%252fcgi-bin%252fsbox%253fnewuser%253dyes&rollrs=03&lic=1

This is a link to MSN Hotmail's Sign Up page where it asks for personal information. If you scroll down, you will notice a subheading called "Your information" in bold. Below this heading you will notice "*Country/Region" listing all possible countries that a user may choose. If, for example, the country Canada is chosen there will be extra options below that combo box listing sub-regions (province/state), but if you are to choose another Country such as Benin the options disappear or if you choose the country Columbia it changes to give you a combo box for "State/Territory".

I want to do this but instead of giving another set of combo boxes, I want it to display text and possibly images in the form.


Also, if you scroll up a bit you will notice that under the sub-heading "Choose your password" that if you decide to type in text in the password fields, some text information will appear on the right side. This is another example of how I would like it to happen but through the option of a combo box.


2.) http://www.javascriptkit.com/script/script2/combodescrip1.shtml

This link provides a sample of a combo box JavaScript script that when a user chooses an option in the combo box, it changes the text within the description box. See, this would be perfect for my uses if it was not just for plain text. I would like to use different styles and fonts and possibly images, as I have said earlier, in a box like this.


3.) http://xkr.us/js/?sel=dynsel

This link is a list of JavaScript elements and when you highlight your mouse over the text of a topic, the title above changes dynamically without a refresh. I would like to do the same thing but have it based on click instead of on mouse over and have it based on a combo box, but possibly just clicking on a link instead. Either will suffice in this case.


This question is worth 500 Points so please try and explain fully with as much detail as possible. Samples/Examples are very welcome, as well as links and other sources.  Thank You all for your support.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-10-03 at 16:49:03ID22011908
Tags

javascript

,

change

,

combo

,

box

Topics

Miscellaneous Web Development

,

Web Development

Participating Experts
2
Points
500
Comments
6

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. DHTML
    What's DHTML and if I don't know HTML, do I need to learn HTML when I leart DHTML? Could you tell me some good web sites for learning HTML, DHTML and JavaScript ?
  2. DHTML
    I have a DHTML outline that works in IE great. I am hoping there is a way to have cross browser DHTML that would allow me to have this outline work in both IE and Netscape... You can find the page at: http://home1.gte.net/mvmmvm/bor/sitemap.html thanks
  3. All country list
    I want 2 list all the countries in the project. Is there any database available with the country list and how i can include it in my php project
  4. What is DHTML
    1 What is DHTML, dynamicHTML? 2 Is it a whole new language with its own syntax? 3 Is there much to it if you know HTML and ASP?
  5. How to set NLS_TERRITORY with OraOleDB and VB6
    Hi, On some of our clients, the NLS_LANG parameter is set to the wrong country. Therefore, the day numbering is wrong. The first day of the week is SO, but should be MO. That I do not need to change the NLS_LANG parameter on each client, I would like to use the ALTER SESSION...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Clever_BobPosted on 2006-10-03 at 21:12:33ID: 17656863

The first thing I would advise is DONT DO IT whatever it is.

I've tried three different combinations of common browsers/OS and I can't view the page properly through my corporate internet that I would say is a typical setup.

 

by: GamerXLTPosted on 2006-10-03 at 23:10:04ID: 17657309

Which page are you reffering to? The links I have provided above, in my original question? I am using Microsoft Internet Explorer 7.0.5700.6 on Microsoft Windows XP Professional (Service Pack 2) and all links provided work well. If you cannot view these links, then possibly it is due to your corporate setup. Firewalls, routers, and other typical corporate setups are usually geared for business purposes, specifically, and sometimes companies block out MSN Hotmail or other scripts like JavaScript or ActiveX applications or what not. In doing so, this type of setup might effect your viewing capabilities.

 

by: b0lsc0ttPosted on 2006-10-04 at 10:08:34ID: 17660959

GamerXLT,

If I understand you correctly the effect you are looking for is done with or called AJAX.  To confirm this or to get information on this you could first look at the Wikipedia page on this (http://en.wikipedia.org/wiki/Ajax_%28programming%29).  If it sounds like what you want then the best tutorial and explanation I have found for it is at http://www.skeymedia.com/programming/classic-asp-and-ajax-tutorial/.  If you use a different server language than ASP then don't worry.  That part of the code is not as important.  The key to what is done is in the client side script (i.e. JavaScript) and the XMLHttpRequest object.  This information should at least help to confirm that I understood you correctly and should also help you get going.


Let me know if you have any questions or need more information.

b0lsc0tt

 

by: GamerXLTPosted on 2006-10-04 at 18:13:44ID: 17665049

Wow, I definately am impressed. I have never heard of AJAX (Asynchronous JavaScript) before, but now I love it. It definately, dynamically updates with very low overhead. If you go to http://www.clearnova.com/ajax/ you will see an example/sample named "Google Suggest Hack" and when you click on the title and type a string within the box, you will instantly see it search for results as you type. No reloading needed. I also found an a dynamic content script using AJAX methods:

Information:
http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-content

Demo/Sample/Example:
http://www.dhtmlgoodies.com/scripts/ajax-dynamic-content/ajax-dynamic-content.html

Download:
http://www.dhtmlgoodies.com/scripts/ajax-dynamic-content/ajax-dynamic-content.zip

In the demo, you will notice in the 'externalfile3' part that when you click on the highlighted "here" it updates automatically. This is exactly what I wanted to do but with a combobox which is simply having the combobox call on the AJAX function, which is just as easy. In the Demo/Sample/Example, the function call is:

ajax_loadContent('news1','external/externalfile1.html');


That is definately step 1 of 2 accomplished in my goal.

The last problem I need to figure out is how to call that function using a combobox via JavaScript.  I'm assuming you set a value for each option and use the OnChange="" syntax in the <select> tag, but I'm not sure how I would go about calling the ajax_loadContent() and inserting the values into them.

Would someone be able to assist with a snippet of code that creates a combobox and inserts two variables into a function?
Pseudo-Code logic would be:

----
Variable1 = 'Table1'
Variable2 = 'external/index.html'
Option1 = Variable1, Variable2

*User selects Option1 on combobox*

ajax_loadContent(Option1);

------

Note: ajax_loadContent(Option1); = ajax_loadContent(Variable1,Variable2);

Thank you b0lsc0tt for the assistance. That was the best solution so far, I just need my second part of the solution now.

 

by: GamerXLTPosted on 2006-10-05 at 00:21:11ID: 17666456

Alright, I have figured out the final solution to all of my needs. I have found that AJAX not only allows an advantage in this single purpose but also allows for a user to template a website very easily. Say you have a common Table of Contents and a banner/logo, all you would have to do is make one template of that and it would reffer to all the other links using the AJAX function calls, depending on the link clicked on and all without the need to constantly refresh the page. This, potentially, saves alot of bandwidth, processing power, and all sorts of delays.

Anyways, I will provide all necessary links, below, to emulate the same procedure and to further understand my problem, from the original post/question.


1.) http://vyrsace.dyndns.org/Demo/demo.html

This is a link to my server that will be up, temporarily, for the next week or so (possibly longer). This fully demonstrates the whole process.

2.) http://www.megaupload.com/?d=LSZM3AQ4

This is a link to a zipped version of my demo. Included in the zip file is:

demo.html - Accesses  content in file1.html, file2.html, file3.html through the combobox on the top left corner. file4.html is accessed through the combobox option "External File 3" and by clicking on the "here" link.
file1.html - Content that is accessed through demo.html
file2.html - Content that is accessed through demo.html
file3.html - Content that is accessed through demo.html
file4.html - Content that is accessed by clicking on the "here" link of file3.html


3.) Below is the sources to the files

demo.html:

<html>
<head>
      <title>AJAX Dynamic Content Demo</title>
      <style type="text/css">
      /* This CSS is only needed for the demo */
      body{
            margin:10px;
            font-size:0.9em;
            font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;
            text-align:center;
            background-color:#E2EBED;
            height:100%;
      }
      a{
            color:#F00;
      }

      
      #mainContainer{
            width:760px;
            margin:0 auto;
            text-align:left;
            background-color:#FFF;
            height:100%;
            padding-bottom:10px;
      }

      #mainContainer .news{
            margin:5px;
            border:1px dotted #555;
            background-color:#EEE;      
            padding:10px;
      }
      
      #mainContainer img{
            float:left;
            margin:2px;
      }
      div#header{
            border:0px;
            background-color:#FFF;
            padding:0px;
            margin:0px;
            height:100px;
      }
      
      h2{
            font-size:1.3em;
            margin-bottom:5px;
      }
      p{
            margin-top:0px;
      }
      .clear{
            clear:both;
      }
      h2{
            color:#000;
      }
      
      #news2{
            height:150px;
      }
      .header{
            padding-left:5px;
            font-weight:bold;
      }
      </style>
      <script type="text/javascript" src="js/ajax.js"></script>
      <script type="text/javascript" src="js/ajax-dynamic-content.js"></script>
      
      
</head>
<body>
      <div id="mainContainer">
            <p class="header">
      
            <select onchange="var val = this.value.split('|'); ajax_loadContent(val[0], val[1])" name="D1">
            <option value=""></option>
            <option value="Body|file1.html">External File 1</option>
            <option value="Body|file2.html">External File 2</option>
            <option value="Body|file3.html">External File 3</option>
            </select>

            </p>
            
            <div class="news" id="Body"><!-- Empty div for dynamic content -->Loading news. please wait...</div>            

      </div>
      
      <script type="text/javascript">
            ajax_loadContent('Body','file1.html');
      </script>

</body>
</html>


file1.html:

<h2>External file 1</h2>
<p>The text you see here is an external file which is loaded into this HTML element by use of Ajax.</p>
<p>This is simply done by the following Javascript function call: ajax_loadContent('news1','external/externalfile1.html'). Two arguments are sent
to this function</p>
<ol>
      <li>The id of the element you want to update, example: "news1" for &lt;div id="news1">&lt;/div></li>
      <li>The path to the external file.</li>
</ol>

file2.html:

<h2>Another external file</h2>
<p><img src="images/demo_image1.jpg">This is also content from an external file.</p>
<p>This file also contains an image taken from a beautiful Island at the west coast of Norway</p>
<br>
<br>

file3.html:

<h2>The name of this file is externalfile3</h2>
<p>If you you want to swith content of this div, click <a href="#" onclick="ajax_loadContent('Body','file4.html');return false">here</a></p>

file4.html:

<h2>Another external file</h2>
<p>Wanna switch back to the previous file?, click <a href="#" onclick="ajax_loadContent('news3','external/externalfile3.html');return false">here</a></p>

demo_image1.jpg (even, though, this can be any image): http://img134.imageshack.us/img134/486/demoimage1eg6.jpg


 

by: b0lsc0ttPosted on 2006-10-05 at 08:56:08ID: 17669810

GamerXLT,

Thanks for the great details on how you used it.  I'm glad that I could help.  I have also been VERY impressed with it.  Very cool effect on a website.  Thank you for the grade, the points and the fun question.

bol

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...