Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||

  • #3
    New Coder
    Join Date
    Feb 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts

  • #5
    New Coder
    Join Date
    Feb 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    theres more to ajax than drop down menu's do some homework.

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    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>

  • #8
    New Coder
    Join Date
    Feb 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you very much. The iframe idea was perfect.

    Much appreciated.

  • #9
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •