Jump to content

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


tinfanide

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...