Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 08-28-2009, 05:00 PM   #1
Baseband Member
Join Date: Sep 2008
Posts: 60
Default Javascript help


I want a code in javascript with the form below:

- a select form allow the visitor to chose a topic

- a box under the select form show explaining about the selected topic

I want another script that forces the visitor to insert 15 numbers in the text field

Thank you very much

Feras is offline   Reply With Quote
Old 09-16-2009, 02:08 PM   #2
Solid State Member
Join Date: Sep 2009
Posts: 13
Default Re: Javascript help

Search in google for Dynamic Drive(first place), you will find a website with a great collections of javascript. The second script you request it's there.

perseadrian is offline   Reply With Quote
Old 09-16-2009, 08:49 PM   #3
In Runtime
Daeva's Avatar
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Javascript help

Here is something I typed up real fast.
In the <head> section of your page
<script type="text/javascript">
     var descriptions = new Array(5);
     descriptions[0] = "Description 1";
     descriptions[1] = "Description 2";
     descriptions[2] = "Description 3";
     descriptions[3] = "Description 4";
     descriptions[4] = "Description 5";
     function listChanged(obj) {
          var curIndex = obj.selectedIndex;
          var curValue = obj.options[curIndex].value;
          if(Number(curValue).toString() != 'NaN' || Number(curValue) < 0) { // make sure it's a valid number
              document.getElementById('output').innerHTML = descriptions[curValue];
          } else {
              document.getElementById('output').innerHTML = "Please select an item to view it's description.";
          } // end if/else
      } // end function
Later on in the body section of your page and inside of your form

<select id="itemSelection" name="itemSelection" onchange="listChanged(this);">
 <option value="-1" selected>--Select--</option>
 <option value="0">First Item</option>
 <option value="1">Second Item</option>
 <option value="2">Third Item</option>
 <option value="3">Fourth Item</option>
 <option value="4">Fifth Item</option>

<div id="output">
  Please select an item to view it's description.
Hope this helps.

You can change the text for each of the descriptions and this will be updated when they change options.

If you can provide a little more information about what you're trying to do, I can help with the second script also.
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
Daeva is offline   Reply With Quote
Old 09-21-2009, 07:12 AM   #4
Baseband Member
Join Date: Sep 2008
Posts: 60
Smile Re: Javascript help


Mr. perseadrian
The web site Dynamic Drive is a really library for web scripts

Thank you

Mr. Daeva
Your script is 100% ok

Thanks alot
Feras is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 04:42 AM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0