Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Mel Smith" Newsgroups: comp.lang.javascript Subject: Re: Button doing work as a hot link ?? Date: Sat, 15 Jun 2013 09:27:31 -0600 Lines: 93 Message-ID: References: <1plstexpucyzv$.1xe3vuzhs2bmm.dlg@40tude.net> X-Trace: individual.net IVerBK8sbkFH0xlzugIv8Q+oTLBU8wF/aMM90/maFHBFOyJT1m Cancel-Lock: sha1:w4edFDqqyJgKcgnpG7wT/D3WZQs= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Xref: csiph.com comp.lang.javascript:20307 JJ said: > With that code alone, it'll never work in any web browser. getobj is not > defined anywhere. Insert this function before the gohotlink function: > > function getobj(n) { > return document.getElementById(n); > } > > Or simply replace the gohotlink function with this one: > > function gohotlink() { > var linkobj = document.getElementById("ihotlink"); > linkobj.submit(); > } Hi JJ: Of course, I defined getobj() exactly as you noted above, but failed to include its definition in my example. I have used this for a few months now. It prevents a lot of typing errors for me. Because 1/2 of the time I work/develop in another C-based language (the Harbour language --- xHarbour), I make many mistakes when moving from Harbour to JavaScript several times a day. So, I created some utility string functions (inter alia) for JS that emulate some those functions in Harbour: Here are a few below the starred line. I must say tho that I miss the '$' operator in Javascript. In my harbour language, it is implemented as follows: lFoundit := "MEL" $ upper("isthatmelana##holeorwhat") // looking for letters 'mel' in string // lFoundit returns true (or in harbour --- .T.) So, I use the function partof() below as a substitute -Mel ***************************** function setfocus(cid) { document.getElementById(cid).focus(); } function len(str) { if (str && typeof str === "string") { return str.length; } else return 0 ; } function alltrim(str) { return str.replace(/^\s+|\s+$/g,"") ; } function empty(str) { if (typeof str === "string" && str.length === 0) return true ; if (typeof str === "number" && str.value === 0) return true ; return false ; } function partof(c,str) { return (str.indexOf(c) !== -1) ? true : false ; } function left(cstr,numchars) { if (typeof cstr === "string" && typeof numchars === "number") return cstr.substr(0,numchars) ; return cstr ; } function right(cstr,numchars) { if (typeof cstr === "string" && typeof numchars === "number") return cstr.substring(cstr.length-numchars,cstr.length) ; return cstr ; } function upper(cstr) { return cstr.toUpperCase() ; } function lower(cstr) { return cstr.toLowerCase() ; }