(SOLVED) Mega2560 Sketch to large?

I have a code that reads two 4051 multiplexers that have their address ports connected so they both get read at the "same" time using an arduino Mega 2560 and Ethernet board. The code works very well until I added this code:

client.println("function volt_visibility(id){");
          client.println("if(id==\"Volt\"){");
              client.println("var en= document.getElementById(\"voltcont\")");
              client.println("if(en.style.display==\"block\"){");
                   client.println("document.getElementById(\"voltcont\").style.display=\"none\";document.getElementById(\"voltcontent\").style.display=\"none\";");
              client.println("}else{");
                   client.println("document.getElementById(\"voltcont\").style.display=\"block\"; document.getElementById(\"voltcontent\").style.display=\"block\";");
              client.println("}}");  
        client.println("if(id==\"Temp\"){");
              client.println("if(document.getElementById(\"tempcont\").style.display==\"none\"){");
               client.println("document.getElementById(\"tempcont\").style.display=\"block\";"); 
               client.println("document.getElementById(\"tempcontent\").style.display=\"block\";");      
        client.println("}}}");

I believe that the problem is with the size of the sketch but I am not sure how to make it any smaller. Does anyone have suggestions on how to make it work? I have been trying to research F() macro's to see if the could be an option to help with the size.

Any help is appreciated.

Please find my full code in the comments.

I believe that the problem is with the size of the sketch

Why? It is more likely that you are running out of SRAM.

I have been trying to research F() macro’s to see if the could be an option to help with the size.

It probably would be.

client.println(F(“function volt_visibility(id){”));

PaulS I do not know much about programming so I am really just making a guess in saying I think the sketch is to large.

I wasn't sure if you could use F() macros in the client. print I will try that and see if it helps

THANK YOU!!

should you, as a practice, use the F macro when ever you are using serial print?

This seems to say yes...

But if I am writing code like this

count++
Serial.println(F(count));

Would the serial output be

1
2
3
...

But if I am writing code like this

Then you are doing it wrong. The F() macro is to keep string literals out of SRAM. count is NOT a string literal.

PaulS- so does that mean that any of the code that I have contained in " " is a literal string and I can put in a F() macro?

A string literal represents a sequence of characters that together form a null-terminated string. The characters must be enclosed between double quotation marks. String and character literals (C++) | Microsoft Docs

Yes.

Whenever you're working with constant strings, use F(). Otherwise, all those strings have to end up in SRAM (harvard architecture), and you don't have room for that.

I implemented F() macro's throughout my code and it runs great!!

Thank you for you help!