Jump to content

Recommended Posts

Hello, I am trying to create a form that checks for errors and changes the class of an HTML <li> so it can highlight the error.

 

I need to be able to compare PHP vars on a different page and change the class of the HTML <li> if it is an error.

 

<li id="foli111" class="notranslate">
<label class="desc" id="title111" for="Field111">
Please enter your SteamID here or choose "Anonymous"
</label>
<div>
<input id="steamid" name="Field111" type="text" class="field text medium" value="" maxlength="30" tabindex="3" onkeyup="" />
</div>
</li>

 

I want the class to change from "notranslate" to "notranslate error"

 

Another example is this http://wufoo.com/gallery/templates/online-orders/donation-form/ (the template im using)

Link to comment
https://forums.phpfreaks.com/topic/255171-get-php-to-change-html-classes/
Share on other sites

Obviously, the class parameter is going to need a variable as its value.

 

Your function would determine via a conditional statement whether this variable is "notranslate" or "notranslate error".

 

Then however you execute the code you should get the results you want.

 

PSUEDO CODE EXAMPLE

function whatever(x)
{
   if (x == true)
   {
      var = "notranslate";
   }
   else
   {
      var = "notranslate error";
   }
   return var;
}

class = whatever(x);

// rest of code

 

You find the x variable based on whatever check you are doing to determine what the styling should be.

 

I hope this helps get you going in the right direction.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.