/    Sign up×
Community /Pin to ProfileBookmark

displaying proper value

hi,
i got problem regarding displaying value

<td nowrap>
//for clock i used javascript from [url]http://www.javascriptkit.com/script/cut2.shtml[/url]
<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

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@DaiWelshJun 25.2003 — <? if (isset($_POST["clock"]))?>//getting error

<?echo $_
POST["clock"]; ?>

<? }?>


you are missing an open brace, should be

<?

if (isset($_POST["clock"])) [b]{ // <- missing brace[/b]

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 ?
Copy linkTweet thisAlerts:
@zuzupusauthorJun 25.2003 — 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
Copy linkTweet thisAlerts:
@DaiWelshJun 25.2003 — 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
×

Success!

Help @zuzupus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...