/    Sign up×
Community /Pin to ProfileBookmark

beginner trying to alter a script

Hi all,

I’m trying to amend a script I have, but I’m a bit of a beginner with JavaScript and have no great understanding of it. I’ve got a program that I use for an online betting site that would be very useful if I could alter to something like version 2 below – except it would work 🙂
Basically the program I have below runs fine (Version 1), but I want to add an addition function and have created version 2. That is if you hold down shift key it does something slightly different, almost identical function. Think I’m going wrong somewhere with the If and Else statements.
The code I’m ATTEMPTING to add is the 2 bits in between * * in the second version. I would appreciate any pointers in the right direction, as that is over a week now I’ve been trying to alter this with no success. Think it is failing as soon it comes to bit I’ve added. 🙁

Thanks for any help

Goose

VERSION 1

<SCRIPT LANGUAGE=”JavaScript” defer>
var parentwin = external.menuArguments;
var doc = parentwin.document;
var doc1 = doc.frames[0].parent;
var stake=doc1.prompt(“Please enter your stake”,”2″);
htm=doc.getElementById(‘oRunnerData’);
if (stake!=null) {
for (layHorseNo=0;layHorseNo<doc1.aR.length;layHorseNo++) {
re=new RegExp(“MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”)”,”g <file://)>”);
htm.innerHTML=htm.innerHTML.replace(re,”if(window.event.altKey) {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;inputOddsPlaceB0.value=aR[“+layHorseNo+”][8];CheckStake(‘Place’,’B’,0,1);CheckOdds(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();} else {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;CheckStake(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();}”);
re=new RegExp(“MBD(“+layHorseNo+”,5);PlaceBet(‘L’,”+layHorseNo+”)”,”g <file://)>”);
htm.innerHTML=htm.innerHTML.replace(re,”if(window.event.altKey) {MBD(“+layHorseNo+”,5);PlaceBet(‘L’,”+layHorseNo+”);inputStakePlaceL0.value='”+stake+”‘;inputOddsPlaceL0.value=aR[“+layHorseNo+”][6];CheckStake(‘Place’,’L’,0,0);CheckOdds(‘Place’,’L’,0,0);SubmitBets();FinalProcessBets();} else {MBD(“+layHorseNo+”,5);PlaceBet(‘L’,”+layHorseNo+”);inputStakePlaceL0.value='”+stake+”‘;CheckStake(‘Place’,’L’,0,0);SubmitBets();FinalProcessBets();}”);
horseName=doc.getElementById(“r”+layHorseNo+”c1”);
horseName.innerHTML=”<FONT color=purple>”+horseName.innerHTML+”</FONT>”;
}
}
</SCRIPT>

VERSION 2

<SCRIPT LANGUAGE=”JavaScript” defer>
var parentwin = external.menuArguments;
var doc = parentwin.document;
var doc1 = doc.frames[0].parent;
var stake=doc1.prompt(“Please enter your stake”,”2″);
htm=doc.getElementById(‘oRunnerData’);
if (stake!=null) {
for (layHorseNo=0;layHorseNo<doc1.aR.length;layHorseNo++) {
re=new RegExp(“MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”)”,”g <file://)>”);
htm.innerHTML=htm.innerHTML.replace(re,”if(window.event.altKey) {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;inputOddsPlaceB0.value=aR[“+layHorseNo+”][8];CheckStake(‘Place’,’B’,0,1);CheckOdds(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();} else {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;CheckStake(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();}”);


******************************************************************

htm.innerHTML=htm.innerHTML.replace(re,”if(window.event.shiftKey) {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;inputOddsPlaceB0.value=aR[“+layHorseNo+”][5];CheckStake(‘Place’,’B’,0,1);CheckOdds(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();} else {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;CheckStake(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();}”);


**********************************************************************

re=new RegExp(“MBD(“+layHorseNo+”,5);PlaceBet(‘L’,”+layHorseNo+”)”,”g <file://)>”);
htm.innerHTML=htm.innerHTML.replace(re,”if(window.event.altKey) {MBD(“+layHorseNo+”,5);PlaceBet(‘L’,”+layHorseNo+”);inputStakePlaceL0.value='”+stake+”‘;inputOddsPlaceL0.value=aR[“+layHorseNo+”][6];CheckStake(‘Place’,’L’,0,0);CheckOdds(‘Place’,’L’,0,0);SubmitBets();FinalProcessBets();} else {MBD(“+layHorseNo+”,5);PlaceBet(‘L’,”+layHorseNo+”);inputStakePlaceL0.value='”+stake+”‘;CheckStake(‘Place’,’L’,0,0);SubmitBets();FinalProcessBets();}”);


****************************************************************

htm.innerHTML=htm.innerHTML.replace(re,”if(window.event.shiftKey) {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;inputOddsPlaceB0.value=aR[“+layHorseNo+”][7];CheckStake(‘Place’,’B’,0,1);CheckOdds(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();} else {MBD(“+layHorseNo+”,4);PlaceBet(‘B’,”+layHorseNo+”);inputStakePlaceB0.value='”+stake+”‘;CheckStake(‘Place’,’B’,0,1);SubmitBets();FinalProcessBets();}”);


******************************************************************

horseName=doc.getElementById(“r”+layHorseNo+”c1”);
horseName.innerHTML=”<FONT color=purple>”+horseName.innerHTML+”</FONT>”;
}
}
</SCRIPT>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @goose1888 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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