manipulating webpages using javascript

Go To StackoverFlow.com

-2

For my question, I'll use an example. Let's say someone wanted to create an HTML form that would manipulate or create a webpage according to any request that is submitted in the form by a user. The form would utilize javascript to accomplish this. How would one be able to do this? Also, I'm not just looking for one color option; I want to create a form that changes/creates a bg color according to any request that is submitted in the form (i.e. not just the option of a red background, but multiple colors or decor options). Thanks for any info.

Brandon

2012-04-03 22:22
by user1222009
I am looking at what you haven't tried. : - hjpotter92 2012-04-03 22:23


0

Usually form submission is only used for POST or GET communications with a server. If you want click functionality for some dynamic content use <input type="button" onclick="jsfunction()"> or an anchor tag which calls jsfunction().

2012-04-03 22:25
by Travis J


0

You could use something like this:

HTML:

<div id="foo"> I'm a div! </div> 

JavaScript:

document.getElementById('foo').style.backgroundColor="red";

JavaScript style commands are slightly different than the names of CSS properties. You can do a quick Google search to find a list of them.

2012-04-03 22:28
by Lil' Bits


0

You can ease your work using jQuery:

javascript

document.getElementById('foo').style.backgroundColor="red";

becomes

$('#foo').css('background-color', 'red')

Another plus is, that the name of css attribute in latter is same as it is in HTML.

Read more about jQuery

2012-04-03 22:46
by Petr Újezdský