简体   繁体   English

使用php更改CSS div的属性

[英]changing property of CSS div using php

I am making some changes on an already established website and need to make the following change. 我正在一个已经建立的网站上进行一些更改,需要进行以下更改。

Currently, there are three images and when one of the image is clicked/chosen, a text message displays and after that a next button can be clicked which takes them to the next page. 当前,有三张图像,当单击/选择其中一张图像时,将显示一条文本消息,然后单击下一步按钮,将它们带到下一页。

Currently, the next button (an image) shows right when the page loads, which means that users can click next without selecting an option. 当前,下一页按钮(图像)在页面加载时显示正确,这意味着用户可以单击下一步而不选择任何选项。

The page is already coded with php and javascript and I was thinking of doing a quick and dirty trick. 该页面已经用php和javascript编码,我正在考虑做一个快速而肮脏的把戏。 This is what I am planing: 这是我打算的:

Create a CSS DIV within the html with display=none; 使用display = none在html内创建CSS DIV; and change the property of the DIV to display whenever the text message is displayed. 并更改显示文本消息时显示的DIV的属性。

My question is: is there a way to access and change a property of a DIV using php? 我的问题是:有没有办法使用php访问和更改DIV的属性?

CSS in HTML page: HTML页面中的CSS:

#btnNext{
position:absolute;
display:none;
top:300px;
left:200px;
width:75px;
height:25px;


<?php 
if(isset($_GET['supportID']) && $_GET['supportID'] != "")
{
    if ($_GET['supportID'] == 1)
    {echo "Protecting Geckos and Their Habitats, click next";}
    elseif ($_GET['supportID'] ==2) 
    {echo "Planting, click next";}
?>

Thanks in advance. 提前致谢。

Typically you would 'disable' the button until they click an image. 通常,您将“禁用”按钮,直到他们单击图像为止。 This can be done using the following html: 可以使用以下html来完成:

<input id="btn_next" type="sumit" disabled="disabled"/>

You would then enable this button when the user selects an image, using JavaScript, something like this: 然后,当用户使用JavaScript选择图像时,您将启用此按钮,如下所示:

document.getElementById("btn_next").removeAttribute("disabled");

This implementation would conform to web standards. 此实现将符合Web标准。

If you wanted to stick with your button not appearing at all until the user selects the appropriate option, your code would look something like: 如果您希望用户在选择适当的选项之前完全不显示按钮,则代码将类似于:

<input id="btn_next" type="submit" style="display:none;"/>

With javascript: 使用javascript:

document.getElementById("btn_next").style.display = "block";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM