Results 1 to 5 of 5

Thread: onclick syntax

  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onclick syntax

    The members of this group have helped me figure out how to control the launching of Word templates using vbscript and the Onclick event. I have another newbie question,

    I can't seem to figure out what should be a simple syntax. I must be having a brain seizure or something.

    What I want to do is display a label on the page, such as "Fax Transmital"

    And when that is clicked on, run an onClick Event, such as:

    onClick='MakeNew($path)'

    Could someone be kind with a clue?

    Thanks
    Jim Helfer

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: onclick syntax

    If you want, you can use standard hyperlink syntax and substitute "java script:MakeNew('$path')" for the URL.

    If you don't want the hyperlink look, you can surround the label with <SPAN> and </SPAN> tags and put the onClick= statement in the <SPAN> tag.

    There may be other ways, for example, if the label is a graphic or in its own <DIV>.

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: onclick syntax

    Thanks, I've been playing with the syntax of both span and a, and I can't seem to get anything to work correctly other than exactly what was typed for me in the example code.

    Frontpage, and "AccentHTML" only seems to recognize one error message: "Expected ]" that occurs at a nonsensical line and column number.

    Jim

  4. #4
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: onclick syntax

    Maybe if I candemonstrate what I've tried:




    Label1
    </p>




    Label2
    </p>




    Label3
    </p>




    To create a new document based on test.dot,
    <SPAN onClick='MakeNew("""f:appsoffice2000pfilesMSOffice TemplateWTW StdsWTW fax trans.dot""")'
    STYLE="font-weight: bold;cursor: hand;">Label4</SPAN>
    </p>

    When I click:

    Label1: "Expected ']'
    Label2: Unterminated String Constant
    Label3: Syntax Error
    Label4: fires script as expected (this is the copied code)

    These error messages all seem to be non-sequitors, and don't help me at all when trying to figure out what the "secret syntax" might be.

    Like I said before, I'm a newbie at this. What happened was, one of my users spent a lot of time in FrontPage making a bunch of usefull pages for an Office Intranet. Once he was done, he came to me to customize all the links to get them to do exactly what he wanted. So, I'm trying to figure out all the programming and all the tags, and all the Frontapage all at once (the user has never seen any HTML at all. Just FP).
    This particular link needs to get nestled in some cell-like structure, so I'm not sure if I can use the SPAN keword. But I guess I am going to try now.

    I'd apreciate if anyone could clue me in on where I'm going wrong on the above. I don't think the change requests are going to stop anytime soon, so I'd like to get a handle on these basics.

    Thanks
    Jim H

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: onclick syntax

    Label1

    There are WAY too many quotation marks in this link. JavaScript does not have a problem with spaces in paths, only Windows has a problem with this, so you'll need to deal with adding the quotation marks inside your script, not in the link. Try this:

    Label1

    (Note: I forgot the ; before. Not sure IE is strict about this, but it seems best to add it to the end of any JavaScript statement for good measure.)

Posting Permissions

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