Solved

send css information of the input field

Posted on 2014-02-10
9
315 Views
Last Modified: 2014-02-17
Is it possible to send the css information of the input field when the form is submitted?
0
Comment
Question by:myyis
  • 4
  • 3
  • 2
9 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39848733
Yes, but it takes a lot of forethought.  This is a very unusual request.  Can you please explain why (in non-technical business terms) you would want to do this?  What problem does it solve?
0
 

Author Comment

by:myyis
ID: 39848742
I am manipulating the css structure of the form with js and want to keep the new css info on database
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 39849908
OK, I don't think that's a non-technical business explanation, but I can understand the idea, I think.  

You're using classes to add and remove the CSS characteristics, right?  

You should be able to add the class name to more than one element.  When you add it as a class on the name of one visual element, you could also add it as a value on a hidden form control, and simultaneously make an AJAX call to the background script that would update the data base.

Though it is potentially much more complex, you should also be able to read the important CSS characteristics of an element (there are a lot of characteristics) and put these into an array.  Then you might create a JSON string from the array and pass that to the AJAX call.  Like the class name, the JSON string could be stored in the data base.
http://api.jquery.com/css/

It's an interesting research project, but I see nothing standing in the way of proving the theory.  If you're new to jQuery and AJAX requests, this article may help you get started.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:myyis
ID: 39849986
Thank you very much.

I think I will go with the 2nd alternative.
Can you explain the below more? An example would be great!

"Though it is potentially much more complex, you should also be able to read the important CSS characteristics of an element (there are a lot of characteristics) and put these into an array. "
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39850033
It's a research project for me, just as it would be for you.  If I have time today or tomorrow I'll try to show you a basic framework for this.  Start with a good understanding of these references:
http://api.jquery.com/css/
http://api.jquery.com/category/css/

Your first jQuery script might try to get something simple like the class name or the width of an element.  You can use JavaScript alert() to prove that you've accessed the right information.
0
 

Author Comment

by:myyis
ID: 39851738
I will try thank you.
0
 
LVL 34

Expert Comment

by:Slick812
ID: 39854366
greetings myyis, , There may or may not be a straight-forward way to do this in javascript and change the "Form" inputs to send the current Class and CSS settings for any particular <input>,  OR for ALL of the <input>, , it will depend on how complex the "changes" are and how you "Restructure" the next output Form with CSS from a database Read of the previous CSS settings. It would help me if you can show the form HTML and maybe some part of the CSS structuring that it has, and then tell about the CSS that needs to be in the Next Form settings.
0
 

Author Comment

by:myyis
ID: 39855019
Hi all,
I think I will follow this way, seems to me easy,
Just before submitting the form, I will loop over all the inputs and read  the necessary css info with js and write to a specific input tag.
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 300 total points
ID: 39855331
Good deal, but I hope you can read that Input from database storage and then change all CSS in the new (next) form as PHP page output, you may can just write all the <input> -
Class="bold red"
as needed, but you can also redo the javescript calls to redo the CSS standings.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
writing a post to a file that is on same folder and same webserver 5 45
hbo knew my windows software 4 62
Row insertion failed. Array 5 46
Ajax and PHP 4 30
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question