By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,285 Members | 2,232 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,285 IT Pros & Developers. It's quick & easy.

Javascript first to display the contents of what the user selects

P: 82
Here is the situation there is a list of contents from which the user can select the required contents to be displayed, but below these list of contents, the contents are actually displayed in the alphabetical order of the contents name ,to display all of the contents below it takes time even if the user selects some content from the list that will not be displayed until all the contents above is not displayed. I wanted to first display the contents of what the user selects and then display the rest of the contents.
Eg: ant cat dog tiger
ant
.
.
.
cat
.
.
.
dog
.
.
.
tiger
.
.
.
here if user selects the contents of dog to be displayed first and then the rest
ie ant cat tiger has to be displayed. Can somebody help me do it

Thanks
Oct 30 '08 #1
Share this Question
Share on Google+
10 Replies


acoder
Expert Mod 15k+
P: 16,027
Can you post the code that you have so far, so we have a better idea what the problem is and how to solve it.
Oct 30 '08 #2

P: 82
I cant reveal the code can you just give me an idea of how to do it??
Oct 30 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Is it because of some legal requirement?

One reason why I asked for the code is that I'm not sure what the exact problem is. Can you explain in more detail with one or two code snippets.
Oct 30 '08 #4

P: 82
yes legal requirement...
The problem is in the current scenario what is hapenning is that
the page looks something similar to what is shown below
ant cat dog tiger
ant
----
---
---(some details about ant)
cat
----
---
----
dog
---
---
---
tiger
---
---
---
now if the user click on the tiger the deatils about tiger will not be available until the ant cat and dog details are being displayed. I wanted it to first display the contents of tiger and then the contents of ant cat and dog in that order.
I hope am clear this time.
Oct 30 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Without code, I can't be sure about the exact answer, but I'll try to give you a general idea.

If each set of details are contained within separate divs, you can display it using elem.style.display set to 'block' where elem is a reference to the corresponding div.
Oct 30 '08 #6

P: 82
Can you please give a sample code which has this feature??
Oct 30 '08 #7

acoder
Expert Mod 15k+
P: 16,027
An example:
Expand|Select|Wrap|Line Numbers
  1. <select ... onchange="displayDetails(this.value)">
  2. <option value="ant">ant</option>
  3. ...
  4. </select>
  5. <div id="ant" style="display: none">blah blah blah</div>
  6. ...and some more...
  7.  
and the javascript:
Expand|Select|Wrap|Line Numbers
  1. function displayDetails(id) {
  2.     document.getElementById(id).style.display = 'block';
  3. }
As I said, this is generic. You'll have to modify it to your requirements.
Oct 30 '08 #8

P: 82
ok but what exactly the code snippet you gave does??
Oct 30 '08 #9

Tarantulus
100+
P: 114
I have a suspicion that serega can't post code because there is no code..

without trying for yourself you wont get any help, no spoon feeding here.

anyone with a simple understanding of basic JS could work out what is going on there, let's see if you can figure it out ;)
Oct 30 '08 #10

acoder
Expert Mod 15k+
P: 16,027
How about you try it for yourself and see? Of course, you'll need to replace the "..."s with the rest of the code (which I'm sure you can fill in yourself).

Edit: I didn't see your reply Tarantulus.
Oct 30 '08 #11

Post your reply

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