Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-13-2008, 07:02 PM   PM User | #1
KyleT4L
New Coder

 
Join Date: Feb 2008
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
KyleT4L is an unknown quantity at this point
Simple PHP Question

Hello,

I'm trying to find a way to have a dropdown menu, and depending on your selection a different paragraph of information will appear on the screen.

I'm pretty sure PHP would accomplish this.

If it isn't simple enough to just explain, I would appreciate any helpful literature you can offer.

Thanks!
KyleT4L is offline   Reply With Quote
Old 03-13-2008, 07:04 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
It could accomplish this however the page would require a page refresh but some how I don't think you wanted that.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 03-13-2008, 07:07 PM   PM User | #3
KyleT4L
New Coder

 
Join Date: Feb 2008
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
KyleT4L is an unknown quantity at this point
Well, no, not really--I was hoping for something a little more fluid.

Any suggestions on how else to accomplish this if PHP isn't what I was looking for? The easier the better.
KyleT4L is offline   Reply With Quote
Old 03-13-2008, 07:12 PM   PM User | #4
rafiki
Senior Coder

 
rafiki's Avatar
 
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
Thanked 42 Times in 42 Posts
rafiki will become famous soon enough
AJAX?
__________________
Get Firefox Now
rafiki is offline   Reply With Quote
Old 03-13-2008, 07:23 PM   PM User | #5
KyleT4L
New Coder

 
Join Date: Feb 2008
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
KyleT4L is an unknown quantity at this point
AJAX seems to be, and correct me if I'm wrong, fancy dropdown menus. And, although it's very cool (I've bookmarked it, as I have no doubt I'll need it someday), I'm not really interested in the dropdown menu--I just want a way for, when something is selected from a simple dropdown, information appears below it without a refresh. I'm pretty sure I've seen this done.

Besides, nothing is impossible with the intar-web.

EDIT: And, to be clear, when I see information to appear below it I don't mean a drop down menu. What the dropdown menu LINKS to IS the paragraph of information that appears below it. Does that make sense?

Last edited by KyleT4L; 03-13-2008 at 07:27 PM..
KyleT4L is offline   Reply With Quote
Old 03-13-2008, 08:16 PM   PM User | #6
rafiki
Senior Coder

 
rafiki's Avatar
 
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
Thanked 42 Times in 42 Posts
rafiki will become famous soon enough
theres more to ajax than drop down menu's do some homework.
__________________
Get Firefox Now
rafiki is offline   Reply With Quote
Old 03-13-2008, 08:20 PM   PM User | #7
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Kyle ... how about <iframe> inline frame?

Now, don't everyone jump on me about <iframe>...
I think it's a good solution in his case.

Your link targets the <iframe> ...

<a href='paragraph.html' target='frame1'>view paragraph</a>



Then, define the <iframe> where you want it to be and the size, etc...

<iframe name='frame1' src='default.html' frameborder='0' scrolling='no' width='400' height='400'></iframe>


It will put the contents of "paragraph.html" into the <iframe>
mlseim is offline   Reply With Quote
Old 03-25-2008, 08:25 PM   PM User | #8
KyleT4L
New Coder

 
Join Date: Feb 2008
Posts: 33
Thanks: 3
Thanked 0 Times in 0 Posts
KyleT4L is an unknown quantity at this point
Thank you very much. The iframe idea was perfect.

Much appreciated.
KyleT4L is offline   Reply With Quote
Old 03-26-2008, 06:16 AM   PM User | #9
dancrghd
New to the CF scene

 
Join Date: Mar 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
dancrghd is an unknown quantity at this point
Since you asked about a drop down I would think that a simple javascript would be a better solution in this case.
Something like this:
Code:
<script type="text/javascript">
function changeptext(){
	var box=document.getElementById('selectbox');
	var othertext=document.getElementById('paragraph');
	
	if(box.value == 'a' ){
		othertext.innerHTML = 'This is the text for Selected A';
	}
	else if(box.value == 'b' ){
		othertext.innerHTML = 'This is the text for Selected B';
	}
	else if(box.value == 'c' ){
		othertext.innerHTML = 'This is the text for Selected C';
	}
	else{
		othertext.innerHTML = 'Select a value from the dropdown to get more info';
	}
	
}
</script>


	<select name="any" onchange="changeptext()" id="selectbox">
		<option value="">SELECT SOMETHING</option>
		<option value="a">A</option>
		<option value="b">B</option>
		<option value="c">C</option>
	</select>
<div style="width:200px;background:#E8E8E8" id="paragraph">
	Select a value from the dropdown to get more info
</div>
That way you :
A) Wouldn't Need to Create a seperate page for each paragraph
B) You could easily add the javascript with a php loop to create the paragraph info if you are pulling that from a db.
dancrghd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 12:23 PM.


Advertisement
Log in to turn off these ads.