Click to See Complete Forum and Search --> : document.write with variables printing variables...Will it work?


cablesforless
12-20-2005, 08:49 AM
I can't get this code to work, it worked before I converted it to a string for document.write, so what do i do to get it to be a variable?
(notice I split it up into different variables so I could find the error, but I still can't find it)

<SCRIPT LANGUAGE='JavaScript'>
var custcheckouta
var custcheckoutb
var custcheckoutc
var custcheckoutd
var custcheckoute
var custcheckoutf
var custcheckoutg
var custcheckouth
var custcheckouti
var custcheckoutj
var custcheckoutk
var custcheckoutl
var custcheckoutm
var custcheckoutn
var custcheckouto
var custcheckoutp
var custcheckoutq
var custcheckoutr

if (document.location == document.location)
{
var custcheckouta = "<\/script> \n"
var custcheckoutb = "<SCRIPT LANGUAGE='JavaScript' for='ShippingOption' event='onclick'> \n if (document.frmCheckout4Step3.ShippingOption[0].checked == true) \n { \n document.Frmshipaccount.disabled=false \n document.Frmshipaccount.FedExAccountNumber.disabled=false \n document.Frmshipaccount.fedexfieldset.disabled=false \n document.Frmshipaccount.UPSAccountNumber.disabled=true \n document.Frmshipaccount.upsfieldset.disabled=true \n document.Frmshipaccount.FedExorUPSAAccount[0].checked=true \n document.Frmshipaccount.FedExorUPSAAccount[1].checked=false \n } \n if (document.frmCheckout4Step3.ShippingOption[1].checked == true) \n { \n document.Frmshipaccount.disabled=true \n document.Frmshipaccount.FedExorUPSAAccount[0].checked=false \n document.Frmshipaccount.FedExorUPSAAccount[1].checked=false \n document.Frmshipaccount.UPSAccountNumber.disabled=true \n document.Frmshipaccount.FedExAccountNumber.disabled=true \n document.Frmshipaccount.upsfieldset.disabled=true \n } \n <\/script>\n"
var custcheckoutc = "<SCRIPT LANGUAGE='JavaScript' for='UPSAccountNumber' event='onkeyup'> \n if (document.Frmshipaccount.UPSAccountNumber.value.length == 6) \n { \n document.Frmshipaccount.shipmethfieldset.disabled=false \n document.Frmshipaccount.shipme(0).focus() \n document.Frmshipaccount.FedExorUPSAAccount[0].disabled=true \n document.Frmshipaccount.subcustomship.disabled=false \n document.Frmshipaccount.txtbxcustomship.disabled=false \n document.Frmshipaccount.boxcustship.disabled=false \n document.Frmshipaccount.shipme[0].checked=true \n } \n if (document.Frmshipaccount.UPSAccountNumber.value.length < 6) \n { \n document.Frmshipaccount.shipmethfieldset.disabled=true \n document.Frmshipaccount.FedExorUPSAAccount[0].disabled=false \n document.Frmshipaccount.subcustomship.disabled=true \n document.Frmshipaccount.txtbxcustomship.disabled=true \n document.Frmshipaccount.boxcustship.disabled=true \n } \n <\/script>\n"
var custcheckoutd = "<SCRIPT LANGUAGE='JavaScript' for='FedExAccountNumber' event='onkeyup'> \n if (document.Frmshipaccount.FedExAccountNumber.value.length == 9) \n { \n document.Frmshipaccount.shipmethfieldset.disabled=false \n document.Frmshipaccount.shipme(0).focus() \n document.Frmshipaccount.FedExorUPSAAccount[1].disabled=true \n document.Frmshipaccount.subcustomship.disabled=false \n document.Frmshipaccount.txtbxcustomship.disabled=false \n document.Frmshipaccount.boxcustship.disabled=false \n document.Frmshipaccount.shipme[0].checked=true \n } \n if (document.Frmshipaccount.FedExAccountNumber.value.length < 9) \n { \n document.Frmshipaccount.shipmethfieldset.disabled=true \n document.Frmshipaccount.FedExorUPSAAccount[1].disabled=false \n document.Frmshipaccount.subcustomship.disabled=true \n document.Frmshipaccount.txtbxcustomship.disabled=true \n document.Frmshipaccount.boxcustship.disabled=true \n } \n <\/script>\n"
var custcheckoute = "<SCRIPT LANGUAGE='JavaScript' for='Frmshipaccount' event='onclick'> \n if (document.Frmshipaccount.FedExorUPSAAccount[0].checked == true) \n { \n document.Frmshipaccount.FedExAccountNumber.disabled=false \n document.Frmshipaccount.fedexfieldset.disabled=false \n document.Frmshipaccount.UPSAccountNumber.disabled=true \n document.Frmshipaccount.upsfieldset.disabled=true \n } \n if (document.Frmshipaccount.FedExorUPSAAccount[1].checked == true) \n { \n document.Frmshipaccount.FedExAccountNumber.disabled=true \n document.Frmshipaccount.fedexfieldset.disabled=true \n document.Frmshipaccount.UPSAccountNumber.disabled=false \n document.Frmshipaccount.upsfieldset.disabled=false \n } \n <\/script>\n"
var custcheckoutf = "<SCRIPT LANGUAGE='JavaScript'> \n if (document.frmCheckout4Step3.ShippingOption[0].checked == true) \n { \n document.Frmshipaccount.disabled=false \n document.Frmshipaccount.FedExAccountNumber.disabled=false \n document.Frmshipaccount.fedexfieldset.disabled=false \n document.Frmshipaccount.UPSAccountNumber.disabled=true \n document.Frmshipaccount.upsfieldset.disabled=true \n document.Frmshipaccount.FedExorUPSAAccount[0].checked = true \n } \n if (document.frmCheckout4Step3.ShippingOption[1].checked == true) \n { \n document.Frmshipaccount.disabled=true \n document.Frmshipaccount.FedExAccountNumber.disabled=true \n document.Frmshipaccount.fedexfieldset.disabled=true \n document.Frmshipaccount.UPSAccountNumber.disabled=false \n document.Frmshipaccount.upsfieldset.disabled=false \n document.Frmshipaccount.FedExorUPSAAccount[0].checked=false}<\/script>\n"
var custcheckoutg = "<SCRIPT LANGUAGE='JavaScript'>document.frmCheckout4Step3.txtSpecialInstructions.disabled = true<\/SCRIPT>\n"
var custcheckouth = "<SCRIPT LANGUAGE='JavaScript' for='subcustomship' event='onclick'>\n"
var custcheckouti = "if (document.Frmshipaccount.FedExAccountNumber.disabled==false) \n {var shippingaccnum = document.Frmshipaccount.FedExAccountNumber.value}\n"
var custcheckoutj = "if (document.Frmshipaccount.UPSAccountNumber.disabled==false) \n {var shippingaccnum = document.Frmshipaccount.UPSAccountNumber.value}\n"
var custcheckoutk = "var i = 0 \n while (i<=4) \n {if (document.Frmshipaccount.shipme[i].checked==true) \n {var shippingpref = document.Frmshipaccount.shipme[i].value \n i=5}i = i + 1}\n"
var custcheckoutl = "if (document.frmCheckout4Step3.txtSpecialInstructions.value > '') \n {var shippingordnot = document.frmCheckout4Step3.txtSpecialInstructions.value}\n"
var custcheckoutm = "var shippingpopupmenu = ('Account Number: ' + shippingaccnum + '\n' + 'Shipping Preference: ' + shippingpref + '\n' + 'Order Notes: ' + shippingordnot)"
var custcheckoutn = "var popmeup = confirm('Is this shipping information correct?' + '\n' + shippingpopupmenu)\n"
var custcheckouto = "if (popmeup == true) \n {document.frmCheckout4Step3.txtSpecialInstructions.value = shippingpopupmenu \n document.Frmshipaccount.disabled=true}\n"
var custcheckoutp = "<\/SCRIPT>\n"
var custcheckoutq = "<SCRIPT LANGUAGE='JavaScript' for='submit' event='onclick'>document.frmCheckout4Step3.txtSpecialInstructions.disabled = false<\/SCRIPT>\n"
var custcheckoutr = "<script>\n"
document.write(custcheckouta + custcheckoutb + custcheckoutc + custcheckoutd + custcheckoute + custcheckoutf + custcheckoutg + custcheckouth + custcheckouti + custcheckoutj + custcheckoutk + custcheckoutl + custcheckoutm + custcheckoutn + custcheckouto + custcheckoutp + custcheckoutq + custcheckoutr)
}
//https://www.cablesforless.com/index.asp?PageAction=CARTCHECKOUT&Step=3&Carrier=CUSTOM
</SCRIPT>

FromU2ME
12-20-2005, 12:11 PM
Am, yeah... nice code :S

Do you mind telling which line the problem is on - just to clear that problem?

cablesforless
12-20-2005, 12:17 PM
Below is the whole file. The lines are extended, if you post the code into an editor it will be much clearer. The problem lies inside the SCRIPT LANGUAGE='JavaScript' for='subcustomship' event='onclick'> area. Please help me guys, I'm going nuts... All I keep getting is "Unterminated string constant".


http://www.gt-unlimited.com/portal/newordermenu3.htm


Robert

FromU2ME
12-21-2005, 04:48 AM
First off, change

var custcheckouta
var custcheckoutb
var custcheckoutc
var custcheckoutd
...to one variable, and write

custcheckout = "one text";
custcheckout += "plus this text";
document.write(custcheckout);...then you don't need to use all the extra variables.

Also, why do you place this code within JavaScript? (Picked it up from your website provided)

<SCRIPT LANGUAGE='JavaScript'>
var supermenu = "<form name='Frmshipaccount' disabled=true> \n <table border='0' width='100%' id='table1' style='border-collapse: collapse'> \n <tr> \n <td width='4%' align='center'> \n <b> \n <input type='radio' value='FedEx' name='FedExorUPSAAccount'> \n </b> \n </td> \n <td width='100%' align='left'> \n <b> \n <fieldset id='fedexfieldset' disabled=true> \n <legend> \n <font color='#FF0000'>FedEx Account</font> \n </legend> \n <input type='text' name='FedExAccountNumber' size='25' maxlength='9'> \n </b> \n <sup> No Dashes, Or Spaces</sup> \n </fieldset> \n </td> \n </tr> \n <tr> \n <td width='4%' align='center'> \n <input type='radio' name='FedExorUPSAAccount' value='UPS'> \n </td> \n <td width='100%' align='left'> \n <fieldset id='upsfieldset' disabled=true> \n <legend> \n <font color='#FF0000'> \n <b>UPS Account</font> \n </legend> \n <input name='UPSAccountNumber' size='25' maxlength='6' > \n </b> \n <sup> No Dashes, Or Spaces</sup> \n </fieldset> \n </td> \n </tr> \n <tr> \n <td width='4%' align='left'>&nbsp;</td> \n <td width='100%' align='left'> \n <fieldset id='shipmethfieldset' disabled=true> \n <legend> \n <font color='#FF0000'> \n <b>Shipping Method</b> \n </font> \n </legend> \n <input type='radio' value='Ground' name='shipme'>Ground<br> \n <input type='radio' value='Three Day' name='shipme'>Three Day<br> \n <input type='radio' value='Second Day Air' name='shipme'>Second Day Air<br> \n <input type='radio' value='Next Day Air' name='shipme'>Next Day Air<br> \n </fieldset> \n </td> \n </tr> \n <tr> \n <td width='4%' align='left'>&nbsp;</td> \n <td width='100%' align='left'> \n <fieldset id='boxcustship' disabled=true> \n <legend> \n <b> \n <font color='#FF0000'>Additional Order Notes</font> \n </b> \n </legend> \n <textarea id='txtbxcustomship' disabled=true rows='2' name='S1' cols='45'></textarea> \n </fieldset> \n </td> \n </tr> \n <tr> \n <td width='4%' align='left'>&nbsp;<p>&nbsp;</td> \n <td width='100%' align='left'> \n <input type='button' value='Submit Order Information' name='subcustomship' disabled=true> \n </td> \n </tr> \n <tr> \n <td width='1' align='left' colspan='2' bgcolor='#000000'> \n </td> \n </tr> \n </table> \n </form>"
document.write(supermenu)
</script>