SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict Tizer's Avatar
    Join Date
    May 2002
    Location
    Beach
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Absolutley no Idea.... Help

    Hi

    I am editing a very very old shopping cart for someone which runs totally on Javascript and I reckon its a bit of a nightmare.

    I have a page with a form on it, well it has the following code on it first within the body tag and NO actual form tags!!!

    document.write ('<form method=post name=checkout' + parent.frames[0].tgt + ' action="' + parent.frames[0].act + '&h=' + escape(parent.frames[2].location.href) + '" onSubmit="return parent.frames[0].passwordtest(\'\', \'\')">')
    } else if (document.location.search) {
    document.write ('<form method=post name=checkout>')

    Then it has various text fields with NO form tags at all. Amazingly this actually works - but hey, I know jack sh*t about javascript!

    Which brings me to my question. How do I validate the form?

    I usually use Dreamweaver Form Validation as I know no JavaScript - but it doesn't recognise any fields cos as far as its concerned - there is no form

    Help

    One last thing - how do people get their code to turn different colours when posting??

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Absolutley no Idea.... Help

    Originally posted by Tizer
    I have a page with a form on it, well it has the following code on it first within the body tag and NO actual form tags!!!
    Code:
      document.write ('<form method=post
        name=checkout'
         + parent.frames[0].tgt
         + ' action="'
         + parent.frames[0].act
         + '&h='
         + escape(parent.frames[2].location.href)
         + '" onSubmit="return parent.frames[0].passwordtest(\'\', \'\')">')
    } 
    else if (document.location.search) {
      document.write ('<form method=post name=checkout>')
    Then it has various text fields with NO form tags at all. Amazingly this actually works - but hey, I know jack sh*t about javascript!
    The document.write statement is in effect creating HTML on the fly. Everything contained within the brackets () will be evaluated and rendered to the screen as though it were hard-coded in the HTML, however a "view source" will only display what you've included. You didn't include the whole if statement, but I suspect that further down you'll find the line:
    Code:
    document.write ('<\/form>')
    or something to that effect.

    Originally posted by Tizer
    Which brings me to my question. How do I validate the form? I usually use Dreamweaver Form Validation as I know no JavaScript - but it doesn't recognise any fields cos as far as its concerned - there is no form
    There wouldn't be any form as such until runtime (when the page loads) as that's when the javascript is executed.
    Originally posted by Tizer
    One last thing - how do people get their code to turn different colours when posting??
    Use the # button above to enter monospace code ([code]) into your posts. If you want the colours etc, then you'll have to use the PHP ([PHP]) button. It's not ideal as it's javascript you're quoting and not PHP but it works and it's unlikely to get confused.


    Nice to see a fellow Yorkshireman/woman on here

    Andy
    From the English nation to a US location.

  3. #3
    SitePoint Addict Tizer's Avatar
    Join Date
    May 2002
    Location
    Beach
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi awestmoreland

    It is a Yorkshireman - from Sunny Scarborough - how you doing?

    Thanks for the reply and yup - you were right, there is

    Code:
    document.write ('<\/form>')
    further down the code.

    So basically, remembering I am no Javascript expert, there is no way to validate this form without editing the other scripts (which I ain't going to do) like the main script where this form is sent to....!!!!!

    Sorry - I know no JavaScript

  4. #4
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Tizer
    It is a Yorkshireman - from Sunny Scarborough - how you doing?
    Ay up, yer just down t'road. Nae bad, ta fer askin'
    Originally posted by Tizer
    So basically, remembering I am no Javascript expert, there is no way to validate this form without editing the other scripts (which I ain't going to do) like the main script where this form is sent to....!!!!!
    Seems I was talking out of the back of my head there. If you use document.write, then at runtime you can view the source of the html page created in the same way as any other.

    As the validation is only going to be performed once the page has loaded, perhaps you can save the created page and pump it through Dream Weaver to create the validation as you normally would and then cut and paste the validation routine(s) into the original files?

    If that makes no sense, then feel free to let me know

    I've never used the part of Dream Weaver that you're referring to, so I'm not sure how it would work.


    Andy
    From the English nation to a US location.

  5. #5
    SitePoint Addict Tizer's Avatar
    Join Date
    May 2002
    Location
    Beach
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Eh Up lad - its bloody cold this morning

    Cheers for the help Andy - but I believe that all the pages are held within a double frame set which trigger the JavaScript (if thats possible). I reckon I'll just go for the "red asterix" route and hope that people take note.

    Speak to you soon - and well done Harrogate Town FC (or whatever they are called)

    Laters

    Tye

  6. #6
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Tizer
    Eh Up lad - its bloody cold this morning
    By 'eck, it is an all!

    Are these pages online at the moment?
    If I took a look, then I might be able to help more, but I'm not promising

    As for football, I've no idea. I'm more of a snooker man myself


    Andy
    From the English nation to a US location.


Bookmarks

Posting Permissions

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