The Buffalo PHP User Group Message Board › Mentoring help needed

Mentoring help needed

Ray N.
RayNewman
Buffalo, NY
Post #: 3
I am helping a friend with his website, for free/food :-) have time but from time to time I hit a snag trying to understand, from stuff I search from on the web, so I need some help with small modules/snippets of code to demo.
My history is decades of hardware/firmware for embedded controllers (assembly code for microcontrollers). Thanks for any help. Ray
Ray N.
RayNewman
Buffalo, NY
Post #: 4
Here is example:
<div id = "col2">
<select name="status">
<option value=""></option>
<option value="Active" <?php $status == 'Active';?>>Active</option>
<option value="Inactive" <?php $status == 'Inactive';?>>Inactive</option>­
</select>
</div>
<div id = "col3">
<button type="button" onclick="<?php echo $status;?>)">Click Me!</button>
</div>
I am trying to verify What $status is.
Thanks,
Ray
Steve W.
user 37318562
Fredonia, NY
Post #: 28
Hi Ray,

a few things:

if you only have 2 states (Active or InActive), you'd probably want to use a radio button in your html instead of a select list.

Active?:
<br />

<input
type = 'radio'
name ='status'
value= 'active'
checked="<?PHP if($status == 'Active') { echo "checked" ; } ?>"
> Yes

<br />

<input
type = 'radio'
name ='status'
value= 'inactive'
checked="<?PHP if($status == 'Inactive') { echo "checked" ; } ?>"
> No

<br />


2nd, if you want to test the value of $status in php, just write this somewhere in your code:

<?php print_r($status) ; ?>

Your previous example appears that it was trying to use a javascript "onclick" event on a button to show php status, but that is not valid code. That snippet would be trying to call a jscript function to do something, but php $status is not a js function. if you truely wanted a js func to show the value, you would write:

<button type="button" onclick="alert('php status=' + <?php echo $status; ?> +' '); ">Click Me!</button>

Hope this helps

Ray N.
RayNewman
Buffalo, NY
Post #: 5
Thanks,
I seem to find bits and pieces of what I need on the web:

.styled-select select {
font-family: Courier New;
font-size: 20px;
}


<form method="post" action="test37o.php">
<div id = "col5">
<div class="styled-select">
<select name="firstBox">
<?php
for ($i = 0; $i < $count; $i++) {
echo '<option>'.$opt1a[$i]."</o­ption>";
}
?>
</select>
</div>
</div>
<input type="submit" value="Add to order" name="D19">
</form>

Now I am trying to verify that anything but default was selected before I process submit.
I seem to extract what I need from working samples instead of proper terminology.
Thanks,
Ray
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy