Changing this.form to something else?

Good evening, sorry for the lame subject line. I know 0 about javascript.

Problem: The javascript code I’m using is within a form. I need the results of that form to be part of a bigger form. This is a no-go.

Here’s the full page I’m working on >>

Form code:

 <form id="rgb" name="rgb">
                <input class="color input-sm" name="hex1" onchange=
                "this.form.r1.value=HexToR(this.form.hex1.value); this.form.g1.value=HexToG(this.form.hex1.value);this.form.b1.value=HexToB(this.form.hex1.value);"
                size="8" style=
                "cursor: auto; background-image: none; background-position: 0% 0%; background-repeat: repeat;"
                type="text" value=""> R: <input class="input-sm" name="r1"
                 size="3" type="text"> G: <input class=
                "input-sm" name="g1"  size="3" type=
                "text"> B: <input class="input-sm" name="b1" size="3"
                style="background-image: none; background-position: 0% 0%; background-repeat: repeat;"

This is the javascript in the header:

R = HexToR("#FFFFFF");
G = HexToG("#FFFFFF");
B = HexToB("#FFFFFF");

function HexToR(h) { return parseInt((cutHex(h)).substring(0,2),16) }
function HexToG(h) { return parseInt((cutHex(h)).substring(2,4),16) }
function HexToB(h) { return parseInt((cutHex(h)).substring(4,6),16) }
function cutHex(h) { return (h.charAt(0)=="#") ? h.substring(1,7) : h}

I know nothing about how to edit javascript - I just need to change this so it’s no longer referring to a form, but some other element. Essentially, I cannot have these mini-forms within any other tags. I only need the inputs as variables for the form to submit.

What to do?


And I figured it out on my own.

Glad you managed to solve it before we could reply .:slight_smile:

Remember it would be helpful to others if you post the solution (even if you did find it yourself) as it adds value to the thread.:wink:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.