www.webdeveloper.com
Results 1 to 4 of 4

Thread: displaying proper value

  1. #1
    Join Date
    Jun 2003
    Posts
    181

    displaying proper value

    hi,
    i got problem regarding displaying value

    <td nowrap>
    //for clock i used javascript from http://www.javascriptkit.com/script/cut2.shtml
    <input type="text" class="button" size="1" name="clock">
    <select name="To" size="1" >
    <option selected >8:00</option>
    <option selected >9:00</option>
    <option selected >10:00</option>
    </select>
    </td>
    <td>
    <? if ($_POST["To"] != "clock") {?>
    <?= $line["To"] ?>
    //whats wrong ib below code and how i can get value of clock when no time is selected from To files
    <? if (isset($_POST["clock"]))?>//its not going to this loop
    <?echo $_POST["clock"]; ?>
    <? }?>
    </td>

    its getting only value of To field no matter whether user chooses tiem from To or running clock is there,i want something like when user not select anything from To he will get value of clock and
    if i use this alone
    <? if (isset($_POST["clock"]))?>//getting error
    <?echo $_POST["clock"]; ?>
    <? }?>


    thanks
    arun krishnan

  2. #2
    Join Date
    Feb 2003
    Location
    Derby, UK
    Posts
    456
    <? if (isset($_POST["clock"]))?>//getting error
    <?echo $_POST["clock"]; ?>
    <? }?>


    you are missing an open brace, should be

    <?
    if (isset($_POST["clock"])) { // <- missing brace
    echo $_POST["clock"];
    }
    ?>

    I have removed some of the <? ?> for clarity.

    Also from what is visible here there is no reason that

    if ($_POST["To"] != "clock") {?>

    would ever be false, since 'To' form variable can not be set to 'clock' in the shown code.

    HTH,

    Dai

    P.S.

    <select name="To" size="1" >
    <option selected >8:00</option>
    <option selected >9:00</option>
    <option selected >10:00</option>
    </select>

    this does not make any sense, the select is not a multiple select (and size 1 anyway) so having all three items selected is not correct. It will not cause problems in IE, but is still invalid
    Last edited by DaiWelsh; 06-25-2003 at 07:27 AM.

  3. #3
    Join Date
    Jun 2003
    Posts
    181
    still i dont understood what you mean even though i add the braces still is not working

    i can tell u more clear

    in table
    <td>
    one is running clock and besides that there is option to select time
    </td>
    and there is save button
    actually why i put clock reason suppose user forget to select tiem and click on save he will get clock time else selected time
    hope u understood,how i can use by PHp as isset is not working as no variable is set for clock as its pure javascript used for clock.

    sorry for ur inconvenience

    thanks
    arun krishnan

  4. #4
    Join Date
    Feb 2003
    Location
    Derby, UK
    Posts
    456
    ok, so are you saying that there is no form field called 'clock' (except the button which will not be passed anyway I think)? If so then that value certainly won't be on the server for the PHP to see, since only values in form fields are passed when the form is submitted.

    If you want to use the value from the select or a default of the current time, then any of these should work

    a) have the select set to a default when the form loads - you are already doing this one anyway so 'To' cannot be unselected if the form is submitted.

    b) use javascript to make sure that they select an item from the select box - only relevant if you dont do a)

    c) in your php, if you dont find a 'To' value use the value of the server time (can get it using time() and reformat it using date() to the format you require).

    HTH,

    Dai

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles