/    Sign up×
Community /Pin to ProfileBookmark

Javascript Form

I am trying to make this script that would change the form layout as customers selected different choices. I’m having a bit of trouble when they select “customer provided”, I would like for the drop down menu to default to “White Shirt” and for it to also display “Shirt Color: White”. Currently when I switch to “Customer Provided” it doesn’t show the color right away. Only when I change the options.

Here is the url of the test form.

[URL=”http://www.theprintcenter.com/test.html”]http://www.theprintcenter.com/test.html[/URL]

Also, I think that I’m coding this all wrong, because it seems like I’m over complicating things… I don’t know.. I’m very new to javascript..

Thank you, in advance.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeJan 21.2011 — IE indicates a JavaScript error on line 78. It's happening as the page loads, before any action is taken.

^_^
Copy linkTweet thisAlerts:
@dgurionauthorJan 21.2011 — =/ ... Not sure why it does that... Here is line 78:

[CODE]PC54 = {"0":'Not Specified',"1":'Aquatic Blue',"2":'Ash',"3":'Athletic Heather',"4":'Athletic Maroon',"5":'Black',"6":'Charcoal',"7":'Dark Green',"8":'Harvest Gold',"9":'Kelly Green',"10":'Light Blue',"11":'Lime',"12":'Natural',"13":'Navy',"14":'Orange',"15":'Purple',"16":'Red',"17":'Royal',"18":'Sand',"19":'White',"20":'Yellow'};
[/CODE]
Copy linkTweet thisAlerts:
@dgurionauthorJan 24.2011 — Still trying to figure this out.. If anyone can help me... I'm not sure why IE causes an error.. I'm certain that I'm coding it wrong.. But.. I don't even know how I would go about creating it properly.. If anyone can help, I would greately appreciate it..

Thank you.
Copy linkTweet thisAlerts:
@thraddashJan 24.2011 — There were two functions that needed fixing, IE was basically complaining because the variables were undeclared.

Replace line 72-120 with the below code:

[CODE]function btnClick(btnNum)
{
var tempBtnVal, tempBtn, PC54, shirtcolor, i;
for (i = 1; i <= 20; i++) {
tempBtnVal = document.getElementById('btnVal');
tempBtn = document.getElementById('btn' + i);
tempBtn.style.border=(i==btnNum?'2px solid #ff0000':'2px solid #CCC');
}
PC54 = {"0":'Not Specified',"1":'Aquatic Blue',"2":'Ash',"3":'Athletic Heather',"4":'Athletic Maroon',"5":'Black',"6":'Charcoal',"7":'Dark Green',"8":'Harvest Gold',"9":'Kelly Green',"10":'Light Blue',"11":'Lime',"12":'Natural',"13":'Navy',"14":'Orange',"15":'Purple',"16":'Red',"17":'Royal',"18":'Sand',"19":'White',"20":'Yellow'};
tempBtnVal.value = PC54[btnNum];
shirtcolor = document.getElementById("shirtcolor");
shirtcolor.innerHTML = (tempBtnVal.value);
}

function btnClick2(btnNum)
{
var tempBtnVal, tempBtn, PC61LS, shirtcolor, i;
for (i = 1; i <= 25; i++) {
tempBtnVal=document.getElementById('btnVal');
tempBtn=document.getElementById('abtn' + i);
tempBtn.style.border=(i==btnNum?'2px solid #ff0000':'2px solid #CCC');
}
PC61LS = {
0 : "Not Specified",
1 : "Aquatic Blue",
2 : "Ash",
3 : "Athletic Heather",
4 : "Athletic Maroon",
5 : "Black",
6 : "Charcoal",
7 : "Dark Green",
8 : "Gold",
9 : "Kelly Green",
10 : "Light Blue",
11 : "Lime",
12 : "Natural",
13 : "Navy",
14 : "Orange",
15 : "Purple",
16 : "Red",
17 : "Royal",
18 : "Sand",
19 : "White",
20 : "Yellow",
21 : "Dark Chocolate Brown",
22 : "Sangria",
23 : "Stonewashed Blue",
24 : "Stonewashed Green",
25 : "Cardinal Red"
};
tempBtnVal.value = PC61LS[btnNum];
shirtcolor = document.getElementById("shirtcolor");
shirtcolor.innerHTML = (tempBtnVal.value);
}[/CODE]
Copy linkTweet thisAlerts:
@dgurionauthorJan 28.2011 — Thanks so much, I couldn't figure out what was wrong.. =/

Also, I had another question.. If I'm trying to do a price lookup from a text field..

Lets say the user inputs 12

How would I set it to look up the price from a range like:

1-12 = $1.00 ea/ 13-24 = $2.00 ... etc...

I know how to make it look up single items like:

cost = {"1":5, "2":10, etc...}

But how would I be able to do this for a range of number? =/



Thank you once again for helping me, slowly learning.....
×

Success!

Help @dgurion 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.29,
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,
)...