/    Sign up×
Community /Pin to ProfileBookmark

Pass a variable from a value

I have been searching for days with no luck. I am new to Java/script but know php if that helps.
What I am looking to do, if someone can point me in the right direction is something like [URL=”http://matrixsoftware.virtualave.net/”]This page.[/URL]
How do they pass the color variable from the pallet to the result display on the right? I really would like to learn more about how to do this. Any help would be greatly appreciated.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@p_phreshAug 16.2007 — all your answers at your fingertips...

http://matrixsoftware.virtualave.net/script.js
Copy linkTweet thisAlerts:
@bubbisthedogAug 16.2007 — <i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&gt;
&lt;title&gt;changeIt&lt;/title&gt;
&lt;script type="text/javascript"&gt;
/*changeIt():
--el_id: ID of element for which style will be applied
--prop: CSS property
--val_el_id: input field where CSS property is stated
*/

function changeIt(el_id, prop, val_el_id) {
d = document.getElementById(el_id);
v = document.getElementById(val_el_id);
d.style.cssText += '; '+prop+':'+v.value;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="this_div"&gt;
&lt;span id="hello"&gt;Hello&lt;/span&gt;, &lt;span id="developer"&gt;Developer&lt;/span&gt;!
&lt;/div&gt;
&lt;input id="hello_col_val" type="text" /&gt;
&lt;input type="button" value="Apply Hello color" onclick="changeIt('hello', 'color', 'hello_col_val');" /&gt;
&lt;br /&gt;
&lt;input id="hello_size_val" type="text" /&gt;
&lt;input type="button" value="Apply Hello text size" onclick="changeIt('hello', 'font-size', 'hello_size_val');" /&gt;
&lt;br /&gt;
&lt;input id="dev_col_val" type="text" /&gt;
&lt;input type="button" value="Apply Developer color" onclick="changeIt('developer', 'color', 'dev_col_val');" /&gt;
&lt;br /&gt;
&lt;input id="this_div_bg_val" type="text" /&gt;
&lt;input type="button" value="Apply Background color" onclick="changeIt('this_div', 'background', 'this_div_bg_val');" /&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@azpilotauthorAug 16.2007 — Thank you very much bubbisthedog and p.phresh.

That helps immensely. I understand how it is passed now.

Thanks again!
×

Success!

Help @azpilot spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...