SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    los angeles
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    changing current page contents with radio buttons

    Hello,
    i'm trying to set up a page that has 5 radio buttons at the top of the page and when you select one of them, without needing to hit a 'submit' button, it will change the contents of the second half of the page, which will contain form elements.
    i'm trying to do this without frames or iframes, and am hoping there's a way to do it with cfloop or something.

    thanks in advance for any help possible

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    cfloop?

    i believe i have what you want, it is accomplished by dhtml (javascript and the document object model) entirely in the browser

    feel free to use my code: http://r937.com/sqllinks.cfm

    i shall not explain it because that is the barrier to entry that i impose, you must know what you're doing when you lift code, as much as if you had written it yourself

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    los angeles
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Rudy, thanks a lot for that script, it seems perfect, i'll give it a shot. I agree with you, learning the scripts you snipe is a minimum.
    thanks again for taking your time to help,
    steve

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    los angeles
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Rudy, that's working great. And i pretty much dig what's happening with it (for a non-javascript dude).

    One thing i have been unable to figure out, though, is how to display nothing at all when you arrive at the page (or just display one of the categories) until you click on a radio button, cause as you know, it now displays all of the categories till you click on a radio button.

    I poked around the JS file, but to no avail:

    function show(keyword) {
    if (keyword=="All") {
    for (i=0; i < keywords.length; i++) {
    document.getElementById(keywords[i]).style.display="block";
    }
    }
    else {
    for (i=0; i < keywords.length; i++) {
    document.getElementById(keywords[i]).style.display="none";
    }
    document.getElementById(keyword).style.display="block";
    }
    }


    thanks a lot

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    well, do you see how the show() function works?

    if the parameter passed to it is "All", it shows them all, otherwise it hides them all and shows the one for the parameter that was passed

    what you want is an onLoad script that hides them all
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    minister of propaganda silver trophy Rynoguill's Avatar
    Join Date
    Feb 2004
    Location
    Midsouth
    Posts
    1,373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    rudy,

    i really like this script. can i make a suggestion though. i read this article here on site point: http://www.sitepoint.com/article/sim...usable-forms/2

    if you put the lable tag around the text for the radio buttons then the users should be able to click on the text as well to change the content. now im not sure it would work with your dhtml/js stuff (i know very little about it) but i think it probalby will.

    just a suggestion, hope you dont mind me butting in here
    rynoguill
    Ryan Guill, AKA Mark Roman

  7. #7
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    no, i don't mind, and while you're at it, perhaps you could debug my dhtml and tell me why it doesn't work in firefox


    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  8. #8
    minister of propaganda silver trophy Rynoguill's Avatar
    Join Date
    Feb 2004
    Location
    Midsouth
    Posts
    1,373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937
    no, i don't mind, and while you're at it, perhaps you could debug my dhtml and tell me why it doesn't work in firefox
    what do you mean it doesnt work in firefox? are you talking about the script that you were talking about above? cause it works just fine for me...

    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8
    rynoguill
    Ryan Guill, AKA Mark Roman


Bookmarks

Posting Permissions

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