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 8 of 8
  1. #1
    New Coder
    Join Date
    Aug 2006
    Location
    france
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs down pop-up problem with my form

    Hi!

    I have a problem with my form:

    Her is the code:

    <form action="<?php
    $_GET['css'] = $mycss;
    $myurl = $_SERVER['PHP_SELF']."?css=" . @$_GET['css'];
    $select = "selected";
    ?>" method="get" name="my_form" id="my_form_id">
    <tr>
    <td>My Form :&nbsp;</td>
    <td>
    Choose your style :&nbsp;
    <select name="css" size="1" onChange="this.form.submit();">
    <option value="<?php $mycss = "css/" . $mycss_styles['antique'];echo $mycss;?>">antique</option>
    <option value="<?php $mycss = "css/" . $mycss_styles['ceramique'];echo $mycss;?>">ceramique</option>
    <option value="<?php $mycss = "css/" . $mycss_styles['default'];echo $mycss;?>">default</option>
    </select>
    </td>
    </tr>
    </form>
    The form itself works perfectly. This form has an action on all my page.

    Only problem is that the pop-up does not want to stay to the option (selected item) the user choose 1, 2, or 3.
    I believe I have to write some Javascript ...?
    Where do I put this script?

    Is it possible to write something like:

    onChange="this.form.submit();" "this.form.do_something_else();"
    to solve my problem ?

    TIA

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    PHP Code:
    <form action="<?php
    $_GET
    ['css'] = $mycss;
    $myurl $_SERVER['PHP_SELF']."?css=" . @$_GET['css'];
    $select "selected";
    ?>" method="get" name="my_form" id="my_form_id">
    that code doesn;t give the HTML action attribute a value...it just executes some PHP code, and declares some variables...i think you want:

    PHP Code:
    <form action="<?php
    $_GET
    ['css'] = $mycss;
    $myurl $_SERVER['PHP_SELF']."?css=" $_GET['css'];
    $select "selected";
    echo 
    $myurl;
    ?>" method="get" name="my_form" id="my_form_id">
    to make one of your options selected, use (for example):
    PHP Code:
    <option value="<?php $mycss "css/" $mycss_styles['antique'];echo $mycss;?>" selected="selected">antique</option>
    and this:

    PHP Code:
                             <select name="css" size="1" onChange="this.form.submit();"
    will submit your form when one of the options in the select menu changes...
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    dont understand, can you expand please ?

    EDIT:
    NVM, chump got it lol

  • #4
    New Coder
    Join Date
    Aug 2006
    Location
    france
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    Hi!

    Your code:
    <option value="<?php $mycss = "css/" . $mycss_styles['antique'];echo $mycss;?>" selected="selected">antique</option>
    is ok

    but does not give the answer: what if the user choose the second one? I want the pop-up to be "ceramique" in my example code. I want this pop-up to be "default" if the user choose the 3rd one and stuck to this value on the page...

    Thanks.

  • #5
    New Coder
    Join Date
    Aug 2006
    Location
    france
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    Quote Originally Posted by Anthony2oo4
    dont understand, can you expand please ?

    EDIT:
    NVM, chump got it lol
    Again me... At the top of my page I have:
    <link rel="stylesheet" type="text/css" href="<?php print @$_GET['css'] ?>" />
    </head>
    In the body:
    <form action="<?php
    $_GET['css'] = $mycss;
    $myurl = $_SERVER['PHP_SELF']."?css=" . @$_GET['css'];
    ?>" method="get" name="my_form" id="my_form_id">
    <tr>
    <td>My Form :&nbsp;</td>
    <td>
    Choose your style :&nbsp;
    <select name="css" size="1" onChange="this.form.submit();">
    <option value="<?php $mycss = "css/" . $mycss_styles['antique'];echo $mycss;?>">antique</option>
    <option value="<?php $mycss = "css/" . $mycss_styles['ceramique'];echo $mycss;?>">ceramique</option>
    <option value="<?php $mycss = "css/" . $mycss_styles['default'];echo $mycss;?>">default</option>
    </select>
    </td>
    </tr>
    </form>
    In fact I just want to get the pop-up reflecting the action of the user...

    If 1st is his choice, have "antique" selected. If 2nd (ceramique) is his choice, have "ceramique" selected etc... after his action and stay there until a new choice.

    My script is probably not appropriate... May be Javascript do that. But I just don't know how to in Javascript ...

    Thanks to all and for hints. I hope being a bit more precise...
    Last edited by dimitryous; 08-30-2006 at 03:37 PM.

  • #6
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    Doesn;t look like you need javascript if the form is just submitting to the same page:


    PHP Code:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" name="my_form">
    <tr>
    <td>My Form :&nbsp;</td>
    <td>
    Choose your style :&nbsp;
    <select name="css" size="1">
        <option value="<?php 
        
            $option1 
    "css/" $mycss_styles['antique'];
            echo 
    $option1
            
        
    ?><?
        
        
    if ($_GET['css'] == $option1)
            echo 
    'selected="selected"';
        
        
    ?>>antique</option>
        <option value="<?php 
             
            $option2 
    "css/" $mycss_styles['ceramique']; 
            echo 
    $option2;    
        
        
    ?><?
        
        
    if ($_GET['css'] == $option2)
            echo 
    'selected="selected"';
        
        
    ?>>ceramique</option>
        <option value="<?php 
        
            $option3 
    "css/" $mycss_styles['default'];
            echo 
    $option3
            
        
    ?><?
        
        
    if ($_GET['css'] == $option3)
            echo 
    'selected="selected"';
        
        
    ?>>default</option>
    </select>
    </td>
    </tr>
    </form>
    Last edited by chump2877; 08-30-2006 at 04:02 PM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #7
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,795
    Thanks
    19
    Thanked 156 Times in 147 Posts
    here's a more efficient way to do that:

    PHP Code:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" name="my_form">
    <tr>
    <td>My Form :&nbsp;</td>
    <td>
    Choose your style :&nbsp;
    <select name="css" size="1"><?

    foreach ($mycss_styles as $key => $val)
    {
        
    $option1 "css/".$val;
        echo 
    '<option value="'.$option1.'" ';    
        
        if (
    $_GET['css'] == $option1)
        {
            echo 
    'selected="selected"';
        }
        
        echo 
    ">$key</option>";
    }

    ?></select>
    </td>
    </tr>
    </form>
    the code is far less confusing that way...
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #8
    New Coder
    Join Date
    Aug 2006
    Location
    france
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Problem solved!!!

    Quote Originally Posted by chump2877
    here's a more efficient way to do that:

    PHP Code:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" name="my_form">
    <tr>
    <td>My Form :&nbsp;</td>
    <td>
    Choose your style :&nbsp;
    <select name="css" size="1"><?

    foreach ($mycss_styles as $key => $val)
    {
        
    $option1 "css/".$val;
        echo 
    '<option value="'.$option1.'" ';    
        
        if (
    $_GET['css'] == $option1)
        {
            echo 
    'selected="selected"';
        }
        
        echo 
    ">$key</option>";
    }

    ?></select>
    </td>
    </tr>
    </form>
    the code is far less confusing that way...
    Thanks you Chump2877, You Got It Right!

    You miss
    <select name="css" size="1" onChange="this.form.submit();">
    Keep on the good work!
    Last edited by dimitryous; 08-30-2006 at 04:54 PM.


  •  

    Posting Permissions

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