Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.form.action = ... seems to be screwing up entire app

Status
Not open for further replies.

thibault

Programmer
Sep 8, 1999
44
US
my original action for frmOrder was mailto:<A HREF="mailto:thibault@hotbot.com">thibault@hotbot.com</A>, which worked perfectly &quot;onSubmit&quot;, even if you never closed the page.&nbsp;&nbsp;i added the emailConfirm() function to the &quot;onUnload&quot; method of the &lt;BODY&gt; assuming that it would alter the action for frmOrder until the user closed the page.&nbsp;&nbsp;that way, if it failed, the original &quot;onSubmit&quot; action would already have been taken and would not be affected.<br>unfortunately, that's not what happened.&nbsp;&nbsp;when i run this the original action(mailto:<A HREF="mailto:thibault@hotbot.com">thibault@hotbot.com</A>) is not executed &quot;onSubmit&quot; as it does normally.&nbsp;&nbsp;how is this possible?&nbsp;&nbsp;any ideas as to what i can do to correct this?&nbsp;&nbsp;code below.<br><br>NOTE: the purpose of the change in the action, upon closing the form, was to send a copy of the order to the person who placed the order.<br>tia:)<br><br><br>&lt;HTML&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;Special Order Form&lt;/TITLE&gt;<br><br>&lt;SCRIPT LANGUAGE=&quot;Javascript&quot;&gt;<br><br>var vHolder = 0;<br><br>&nbsp;&nbsp;&nbsp;function setFocus() {<br> document.frmOrder.Store.focus(); // set initial focus<br> vDate = new Date(); // set default date<br> vMonth = vDate.getMonth();<br> vMonth = vMonth + 1;<br> if (vMonth&lt;10) vMonth = (&quot;0&quot; + vMonth.toString());<br> vDay = vDate.getDate();<br> if (vDay&lt;10) vDay = (&quot;0&quot; + vDay.toString());<br> vYear = vDate.getYear();<br> sDate = (vMonth + &quot;/&quot; + vDay + &quot;/&quot; + vYear);<br> document.frmOrder.ordDate.value = sDate;<br>}<br><br><br>&nbsp;&nbsp;&nbsp;function checkLoc_cd(vLoc_cd) { // set vLoc_cd to the proper length<br> if (vLoc_cd.length==0) { // check for null field value<br> &nbsp;&nbsp;&nbsp;&nbsp;if (vHolder==0) {<br> vHolder = 1;<br> document.frmOrder.Store.focus();<br> alert(&quot;A value must be entered in this field.&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;}<br> }<br>&nbsp;&nbsp;&nbsp;if (vLoc_cd.length==2){ // loc-cd must be 3 characters long<br> vLoc_cd = &quot;0&quot; + vLoc_cd;<br> }<br>&nbsp;&nbsp;&nbsp;else if (vLoc_cd.length==1){<br> vLoc_cd = &quot;00&quot; + vLoc_cd;<br> }<br>&nbsp;&nbsp;&nbsp;document.frmOrder.Store.value = vLoc_cd;<br>&nbsp;&nbsp;&nbsp;vHolder = 0;<br>}<br><br>&nbsp;&nbsp;&nbsp;function checkValue(vValue,vName) { // check for null field value<br> if (vValue.length==0) {<br> &nbsp;&nbsp;&nbsp;&nbsp;if (vHolder==0) {<br> vHolder = 1;<br> alert(vName);<br> val = window.eval(&quot;document.frmOrder.&quot;+vName+&quot;.focus()&quot;);<br>/*<br> document.frmOrder.Assoc.focus();<br>*/<br> alert(&quot;A value must be entered in this field.&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;}<br> }<br>}<br><br>&nbsp;&nbsp;&nbsp;function submitIt() {<br> vConfirm = document.frmOrder.Assoc.value.substr(0,2);<br> vConfirm = vConfirm.toUpperCase();<br> vConfirm += document.frmOrder.Store.value;<br> vDate = new Date();<br> vAno = vDate.getYear();<br> vYear = vAno.toString();<br> vYear = vYear.substr(2,2);<br> vConfirm += vYear;<br> vMonth = vDate.getMonth();<br> vMonth = vMonth + 1;<br> if (vMonth&lt;10) sMonth = (&quot;0&quot; + vMonth.toString());<br> else sMonth = vMonth.toString();<br> vConfirm += sMonth;<br> vDay = vDate.getDate();<br> if (vDay&lt;10) sDay = (&quot;0&quot; + vDay.toString());<br> else sDay = vDay.toString();<br> vConfirm += sDay;<br><br> vConfirm += vDate.getHours();<br> vConfirm += vDate.getMinutes();<br> document.frmOrder.ConfirmNo.value = vConfirm; // set value of confirmation number<br>}<br><br>&nbsp;&nbsp;&nbsp;function emailConfirm() {<br> vEmail = &quot;mailto:&quot;<br> vEmail += document.frmOrder.Assoc.value;<br> vEmail += &quot;@ultrastores.com&quot;;<br> document.frmOrder.action = vEmail;<br> document.frmOrder.submit();<br> alert(vEmail);<br>}<br><br><br>&lt;/SCRIPT&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY onLoad=&quot;setFocus();&quot; onUnload=&quot;emailConfirm();&quot;&gt;<br>&lt;IMG SRC=&quot;ultstore.jpg&quot; align=center HEIGHT=28 WIDTH=180&gt;<br>&lt;CENTER&gt;&lt;H3&gt;SPO Department Inquiry & Order Form&lt;/H3&gt;&lt;/CENTER&gt;<br><br>&lt;FORM NAME=&quot;frmOrder&quot; ACTION=&quot;mailto:<A HREF="mailto:thibault@hotbot.com">thibault@hotbot.com</A>&quot; METHOD=&quot;POST&quot; ENCTYPE=&quot;text/plain&quot;<br> onSubmit=&quot;submitIt();&quot;&gt;<br>&nbsp;&nbsp;&lt;INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;ConfirmNo&quot;&gt;<br>&nbsp;&nbsp;&lt;TABLE WIDTH=&quot;95%&quot; BORDER=1&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TR&gt;&lt;TD&gt;Store&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=3 NAME=&quot;Store&quot; onBlur=&quot;checkLoc_cd(value);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;Associate Login ID&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;Assoc&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;Today's Date&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;ordDate&quot; VALUE=&quot;6/23/00&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD COLSPAN=2&gt;Date Order Needed In Store&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;Needed&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TR&gt;&lt;TD COLSPAN=3&gt;Customer Name&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;30&quot; NAME=&quot;Guest&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD ROWSPAN=3 COLSPAN=2&gt;&lt;B&gt;One option must be selected&lt;B/&gt;&lt;BR&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;INPUT TYPE=&quot;RADIO&quot; NAME=&quot;RequestType&quot; VALUE=&quot;0&quot; &gt;50% DEPOSIT AMOUNT&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;INPUT TYPE=&quot;RADIO&quot; NAME=&quot;RequestType&quot; VALUE=&quot;1&quot; &gt;PAID IN FULL AMOUNT&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;INPUT TYPE=&quot;RADIO&quot; NAME=&quot;RequestType&quot; VALUE=&quot;2&quot; &gt;TRANSFER/EXCHANGE&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;INPUT TYPE=&quot;RADIO&quot; NAME=&quot;RequestType&quot; VALUE=&quot;3&quot; &gt;INQUIRY ONLY&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TR&gt;&lt;TD COLSPAN=3&gt;Address&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;40&quot; NAME=&quot;Domicile&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TR&gt;&lt;TD COLSPAN=2&gt;Home Phone&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;20&quot; NAME=&quot;Home&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;Work Phone&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;20&quot; NAME=&quot;Work&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TR&gt;&lt;TD&gt;SKU to reference&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;SKU&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;Metal&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;metal&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;Color&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;color&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;Size/Length&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;size&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;Retail&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;15&quot; NAME=&quot;retail&quot; onBlur=&quot;checkValue(value,name);&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TR&gt;&lt;TD COLSPAN=5&gt;Special Instructions&lt;BR&gt;&lt;INPUT TYPE=&quot;TEXT&quot; SIZE=&quot;55&quot; NAME=&quot;instructions&quot;&gt;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TR&gt;&lt;TD COLSPAN=5&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;INPUT TYPE=&quot;submit&quot; VALUE=&quot;Submit&quot; ACTION=SUBMIT&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;INPUT TYPE=&quot;reset&quot; VALUE=&quot;Reset&quot; ACTION=RESET onClick=&quot;setFocus();&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TR&gt;<br>&nbsp;&nbsp;&lt;/TABLE&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Arial&quot; SIZE=2&gt;Copyright Ultra Stores, Inc. 2000&lt;/FONT&gt;<br>&lt;/FORM&gt;<br>&lt;/BODY&gt;<br>&lt;/HTML&gt; <p>bobbie<br><a href=mailto:thibault@hotbot.com>thibault@hotbot.com</a><br><a href= </a><br>
 
Dear bobbi,<br><br>try returning 'true' from submitit(), i.e.,<br><br>function submitit(){<br>... stuff<br>&nbsp;&nbsp;return true;<br>}<br><br>Hope this helps<br>-pete<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top