Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Syntax issue with hidden value from url

    Hi All,

    I have been trying to help a friend out(for real! She is a designer and I'm a developer but not very familiar with Javascript)

    The situation: she is coming in from another page and is passing a value called "chargetotal" in the url(agree it's probably not the best way but she's not in a position to re-write the whole thing). When on this page, she needs to post some information to a secure bank site. One of the things she needs to send is "chargetotal". She is attempting to do this by taking the value from the url, put it into a hidden form variable and then post it. If she hard codes the value it all works - but it doesn't work with the hidden value so clearly the syntax is all wrong. Here is the page:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// 
    www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; 
    charset=iso-8859-1" /> 
    <title>Payment Page</title> 
    </head> 
    
    
    <script type='text/javascript'> 
    function parseGetVars() { 
            var getVars = new Array(); 
            var qString = unescape(top.location.search.substring(1)); 
            var pairs = qString.split(/\&/); 
            for (var i in pairs) { 
                    var nameVal = pairs[i].split(/\=/); 
                    getVars[nameVal[0]] = nameVal[1]; 
                    } 
            return getVars; 
            } 
    </script> 
    
    
    <body> 
    
    
    <table width="507" border="0" align="center" bgcolor="#FFFFFF"> 
      <tr> 
        <td height="31"><p align="center"><font color="#660000" size="6" 
    face="Bookman Old Style">Payment 
            Options TEST</font></p></td> 
      </tr> 
      <tr> 
        <td height="358" valign="top" background="images/badge.gif"><div 
    align="center"><font size="2" face="Geneva, Arial, Helvetica, sans- 
    serif"><br /> 
    
    
    <br /> 
        </font> </div> 
            <table width="715" height="52" border="0"> 
              <tr> 
                <td align="center" width="374" height="48"> 
                            <form name="form1" method="post" action="https://secure.bANK.net/ 
    lpcentral/servlet/lppay"> 
        <script type='text/javascript'> 
        var g = parseGetVars(); 
        for (var i in g) 
        document.writeln('Your total fee is $' +g[i]+'<br>'); 
     document.forms.form1.FeeCalcTotalDecimal.value  = '+g[i]+' ; 
        </script> 
                            <input type="hidden" name="txntype" value="sale"> 
                                    <input type="hidden" name="storename" value="1001184858"> 
                                    <INPUT type="hidden" name="chargetotal" value=""> 
                                    <input type="hidden" name="suppressTitle" value="true"> 
                                    <input name="Submit" type="submit" id="Submit" value="Submit"> 
                                    </td> 
                <td width="331"> 
                    </div> 
                </form></td> 
              </tr> 
            </table> 
          <div align="center"><font size="2" face="Geneva, Arial, 
    Helvetica, sans-serif"> 
    
    
          </font></div></td> 
      </tr> 
    </table> 
    </body> 
    </html>
    Realize that this pretty basic stuff for anybody with good knowledge
    of Javascript - but that is not us! So, you have our eternal thanks
    for your assistance!

  • #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    First of all, the script tags should be inside of the head tags (at least the first script tag).
    Secondly, The following statement would write +g[i]+:
    Code:
     document.forms.form1.FeeCalcTotalDecimal.value  = '+g[i]+' ;
    You should remove the single quotes from it.

  • Users who have thanked BarrMan for this post:

    JCCDevel (04-29-2008)

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    It guess you want something like that:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// 
    www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /> 
    <title>Payment Page</title> 
    <script type='text/javascript'> 
    /*<![CDATA[*/
    onload=function(){
    var qString = unescape(top.location.search.substring(1)); 
    var qName=qString.split('&')[1].split('=')[0];
    var qValue=qString.split('&')[1].split('=')[1];
    document.forms['form1']['chargetotal'].value=qValue;
    document.getElementById('tot').firstChild.nodeValue='Your total fee is $' +qValue;
    }
    /*]]>*/
    </script> 
    </head> 
    <body> 
    <table width="507" border="0" align="center" bgcolor="#FFFFFF"> 
      <tr> 
        <td height="31"><p align="center"><font color="#660000" size="6" 
    face="Bookman Old Style">Payment 
            Options TEST</font></p></td> 
      </tr> 
      <tr> 
        <td height="358" valign="top" background="images/badge.gif"><div 
    align="center"><font size="2" face="Geneva, Arial, Helvetica, sans- 
    serif"><br /> 
    
    
    <br /> 
        </font> </div> 
            <table width="715" height="52" border="0"> 
              <tr> 
                <td align="center" width="374" height="48">
    			<div id="tot">&nbsp;</div> 
                            <form name="form1" method="post" action="https://secure.bANK.net/lpcentral/servlet/lppay"> 
        
                            <input type="hidden" name="txntype" value="sale" /> 
                                    <input type="hidden" name="storename" value="1001184858" /> 
                                    <input type="hidden" name="chargetotal" value="" /> 
                                    <input type="hidden" name="suppressTitle" value="true" /> 
                                    <input name="Submit" type="submit" id="Submit" value="Submit" />
    								</form> 
                                    </td> 
                <td width="331"> </td> 
              </tr> 
            </table> 
          <div align="center"><font size="2" face="Geneva, Arial, 
    Helvetica, sans-serif"> 
    
    
          </font></div></td> 
      </tr> 
    </table> 
    </body> 
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • Users who have thanked Kor for this post:

    JCCDevel (04-29-2008)

  • #4
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you both for your suggestions. I will have her try these out. I truly apprecuate the time you took to help!

    Julie


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •