/    Sign up×
Community /Pin to ProfileBookmark

Help With Multiple Instances of 3 Javacripts?

Hello:

I have 3 javascripts running the form for the ‘Labrador Retriever’ section of the following page: BTW, the forms pass to a shopping cart. All forms work GREAT in this example:

[url]http://www.familycarstickers.us/dogordering1_20_atc_hc.htm[/url]

Here’s where the trouble starts ? I want to apply these same JS to another 19 ‘breeds’ of dogs with the same form features on this same page:

Here’s my failed attempt at trying to add another breed (terrier) with the same features of the first, all while trying to pass FULL info to the cart – price, options and price-adjusting options.

[url]http://www.familycarstickers.us/dogordering1_20_atc_hc2.htm[/url]

The 3 Javascripts are as follows…I’m not a scripter, obviously, been working at this for a few days and have some great help, but need the functoinality described. Thanks for any clues? LS

<script Language=”JavaScript”>
<!–
function confirm_p1()
{

// Check to see if the dropdown value is is the first choice
if (the_form.p1.selectedIndex == 0)
{

// If the first choice is selected display an alert box
// stating the first choice is not a valid selection
alert(“Please Select a Design”);

// Focus on the dropdown menu after OK is clicked from the alert box
the_form.p1.focus();
return (false);
}
// A choice other than the first was selected
// cotinue processing the form request
return (true);
}
//–></script>

<script type=”text/javascript”>

var Labrador = [
‘Select|[url]http://www.familycarstickers.us/decalimages/labradorret1G.gif[/url]‘,
‘Design #1|[url]http://www.familycarstickers.us/decalimages/labradorret1.gif[/url]‘,
‘Design #2|[url]http://www.familycarstickers.us/decalimages/labradorret2.gif[/url]‘,
‘Design #3|[url]http://www.familycarstickers.us/decalimages/labradorret3.gif[/url]‘ // NOTE: no comma after last entry
];

var YorkshireTerrier = [
‘Select|[url]http://www.familycarstickers.us/decalimages/terrier1G.gif[/url]‘,
‘Design #4|[url]http://www.familycarstickers.us/decalimages/terrier1.gif[/url]‘,
‘Design #5|[url]http://www.familycarstickers.us/decalimages/terrier2.gif[/url]‘,
‘Design #6|[url]http://www.familycarstickers.us/decalimages/terrier3.gif[/url]
];

var GermanShepherd = [
‘Select|[url]http://www.familycarstickers.us/decalimages/GermanShepherd1G.gif[/url]‘,
‘Design #7|[url]http://www.familycarstickers.us/decalimages/GermanShepherd1.gif[/url]‘,
‘Design #8|[url]http://www.familycarstickers.us/decalimages/GermanShepherd2.gif[/url]‘,
‘Design #9|[url]http://www.familycarstickers.us/decalimages/GermanShepherd3.gif[/url]
];

var Beagle = [
‘Select|[url]http://www.familycarstickers.us/decalimages/GermanShepherd1G.gif[/url]‘,
‘Design #13|[url]http://www.familycarstickers.us/decalimages/beagle1.gif[/url]‘,
‘Design #14|[url]http://www.familycarstickers.us/decalimages/beagle2.gif[/url]‘,
‘Desing #15|[url]http://www.familycarstickers.us/decalimages/beagle3.gif[/url]
];

function Populate(IDS,Arr) {
var f=document.getElementById(IDS);
document.getElementById(IDS).options.length=null;
for (i=0; i<Arr.length; i++) {
tmp = Arr[i].split(‘|’);
document.getElementById(IDS).options[i]=new Option(tmp[0], tmp[0]);
}
}

function selectForm(obj) {
var IDS = obj.id;
var divIDS = obj.selectedIndex;
// document.getElementById(‘test’).innerHTML = IDS+’ | ‘+divIDS; // for testing purposes only
document.getElementById(‘img’+IDS).src = window[IDS][divIDS].split(‘|’)[1];
}

</script>

<script language=”JavaScript”
type=”text/javascript”>
<!–
function showHideTextfield(selIndex,frm){
for (var i=3;i<=3;i++){
if(selIndex<=i-3){
frm[‘p’+i].disabled=true;

}
else{
frm[‘p’+i].disabled=false;
}
}
}
//–>
</script>

</script>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@opifexSep 12.2009 — 
<script type="text/javascript">

<!--

function showHideTextfield(selIndex,frm){

[COLOR="Red"]for (var i=3;i<=3;i++){

if(selIndex<=i-3)[/COLOR]
{

frm['p'+i].disabled=true;


}

else{

frm['p'+i].disabled=false;

}

}

}

//-->

</script>

</script>[/QUOTE]

At a glance, looks like the total number of entries needs to be changed to reflect your new number of entries...
×

Success!

Help @luckysigns 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...