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


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

Hello

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
__________________

__________________
SAY NO TO PIRACY
Feras is offline   Reply With Quote
Old 09-16-2009, 03: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, 09: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
Code:
<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
//-->
</script>
Later on in the body section of your page and inside of your form

Code:
<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>
</select>
</form>

<div id="output">
  Please select an item to view it's description.
</div>
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
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 09-21-2009, 08:12 AM   #4
Baseband Member
 
Join Date: Sep 2008
Posts: 60
Smile Re: Javascript help

Hi

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
__________________
SAY NO TO PIRACY
Feras is offline   Reply With Quote
Reply

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 07:07 AM.


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