Find the answer to your Linux question:
Results 1 to 4 of 4
I am working on a simple script in PHP for a simple slideshow. Not i want a few radio buttons, split into groups. One group to control the delay of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790

    Using radio buttons to reload same page


    I am working on a simple script in PHP for a simple slideshow. Not i want a few radio buttons, split into groups. One group to control the delay of the slideshow, and one to control the size of the picture. Now i have the script getting variables out of the address like:
    Code:
    slides.php?ImageNumber=49&&timeout=10&&height=600
    this would be on picture 49 of the total images and have a delay of 10 seconds and be 600px high. Now i want to set the timeout and height through radio buttons, i know it needs to be done thru forms etc, but don't know how exactly to go about it.

    Could anyone help me at all?
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  2. #2
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284

    Re: Using radio buttons to reload same page

    Quote Originally Posted by sdousley
    I am working on a simple script in PHP for a simple slideshow. Not i want a few radio buttons, split into groups. One group to control the delay of the slideshow, and one to control the size of the picture. Now i have the script getting variables out of the address like:
    Code:
    slides.php?ImageNumber=49&&timeout=10&&height=600
    this would be on picture 49 of the total images and have a delay of 10 seconds and be 600px high. Now i want to set the timeout and height through radio buttons, i know it needs to be done thru forms etc, but don't know how exactly to go about it.

    Could anyone help me at all?
    Form data is generally available in the $_POST scope if the form is defind as:
    <form action="page.php" method="POST">
    or the $_GET scope if the form is defined as:
    <form action="page.php" method="GET">
    You then create a group of radio buttons in your form like so:

    Code:
    <input type=radio name="height" value=100>100
    
    <input type=radio name="height" value=250>250
    
    <input type=radio name="height" value=600>600
    Then ad a submit button:
    Code:
    <input type="submit" name="go" value="Change height">
    and close your form:
    Code:
    </form>



    in your PHP page, when the form is submitted, you can work out which radio button was selected like so:

    Code:
    $use_height = 100; //set a default
    
    if&#40; $_POST &#41; //check form was submitted
    &#123;
         if&#40; isset&#40;$_POST&#91;'height'&#93;&#41; &#41;
         &#123;
                   $use_height = $_POST&#91;'height'&#93;;
         &#125;
    &#125;
    The variable $use_height will be available in the rest of your page for you to do whatever with.

    Jason

  3. #3
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    ok, i have it working now with the radio buttons, but i want the page to load the url:
    Code:
    slides.php?ImageNumber=<Same number>&&timeout=<samenumber>&&height=<what you select>
    this code u gave me does change the pic size, but doesn't actually display an image as an image number is not defined in the url.
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  4. #4
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    I now have it.

    Code follows:
    PLace this in the head of html
    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu&#40;targ,selObj,restore&#41;&#123; //v3.0
      eval&#40;targ+".location='"+selObj.options&#91;selObj.selectedIndex&#93;.value+"'"&#41;;
      if &#40;restore&#41; selObj.selectedIndex=0;
    &#125;
    //-->
    </script>
    Then in the body put:

    Code:
      <select name="sizemenu" onChange="MM_jumpMenu&#40;'parent',this,0&#41;">
        <option>Select Height&#58;</option>
        <option value="<?=$_SERVER&#91;'PHP_SELF'&#93;?>?ImageNumber=<?=$ImageNumber?>&timeout=<?=$timeout?>&height=100">100</option>
        <option value="<?=$_SERVER&#91;'PHP_SELF'&#93;?>?ImageNumber=<?=$ImageNumber?>&timeout=<?=$timeout?>&height=400">400</option>
        <option value="<?=$_SERVER&#91;'PHP_SELF'&#93;?>?ImageNumber=<?=$ImageNumber?>&timeout=<?=$timeout?>&height=590">600</option>
    </select>
    assuming you have the variables setup as i do, this will work.
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

Posting Permissions

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