开发者

How to get value from any HTML tag in php variable?

what I am asking开发者_开发知识库 is

I have some value in <p>

eg. <p>Hello</p>

now I want to know is there any way to get the value inside <p> in a PHP variable $getPara

(in session variable or normal variable or global variable)

so that when I write <strong><?php echo $getPara; ?></strong> then it will print Hello


No, you can't.

The browser will submit all form fields (input, select, and textarea) to the server, but it won't send any other data.

You need to use Javascript.


You could look for any element having .includeMe as a class name, and create a form element for it. The next time the form is sent, those items will be sent as values too:

<p class="includeMe" id="state">Georgia</p>

--

$(function(){
  // Everything with class 'includeMe'
  $(".includeMe").each(function(){
    var id   = $(this).attr("id"),
        text = $(this).text(),
        elem = $("<input type='hidden'/>").attr("id", id).val(text);
    // Add to form
    $("form").append(elem);
  });
});


if the problem is with input specifically, then you can use

<textarea name="some_name_to_use_in_php">hello</textarea>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜