Jump to content

Is There Something Like This.value Of Js In Php?


tinfanide
 Share

Recommended Posts

	 <option value="var1" <?php if($var=="this.value"){echo "SELECTED";} ?> >var 1</option>	 <option value="var2" <?php if($var=="this.value"){echo "SELECTED";} ?> >var 2</option>

I know we can refer to the object's value by using "this".But is there an equivalent word in PHP?

Link to comment
Share on other sites

So I cannot refer to the object in HTML like Javascript does?

<option value="ABC" <?php this.value ?> ></option>

Any alternative in PHP for this function?

Link to comment
Share on other sites

No. To PHP, the "<option>" is just pure text, the PHP engine doesn't parse the HTML or work with the DOM in any way before sending the content to the client. If you want the value, then just use the value:

<option value="var1" <?php if($var=="var1"){echo "SELECTED";} ?> >var 1</option><option value="var2" <?php if($var=="var2"){echo "SELECTED";} ?> >var 2</option>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...