Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

anything simpler than document.write() ?

  • 09-08-2004 11:19am
    #1
    Registered Users, Registered Users 2 Posts: 1,280 ✭✭✭


    i'm porting over a college project ( current version can be viewed online at http://www.thegalwaysky.com/starcheck/ ) from ASP to a pure client-side JavaScript application.

    i was wondering if there is a simpler way of writing variables within the body of an html document than every time having to use:

    <script language="JavaScript1.5">
    document.write(myVar);
    </script>

    asp and php have useful shortcuts for writing the values of variables within the html body, eg. <%= myVar %> for ASP. can something similar be done with JavaScript ?

    cheers,
    jAH


Comments

  • Registered Users, Registered Users 2 Posts: 8,452 ✭✭✭Time Magazine


    Try

    var d.w = document.write;

    then try d.w.(myVar);

    Alternatively make a function, e.g. x(myVar), whose command is simply to document.write(). So you get <script>x(myVar)</script> each time. It's a little easier.


  • Registered Users, Registered Users 2 Posts: 1,280 ✭✭✭jArgHA


    cheers banana,

    the x(myVar) function sounds good although i thought there may have been a shortcut for getting rid of the <script> tags also (as in ASP/PHP). ps nice website you've got there.

    grma,
    jAH


  • Registered Users, Registered Users 2 Posts: 1,967 ✭✭✭Dun


    The javascript tags/source can't be removed because the browser runs the javascript on the client computer, whereas PHP/ASP is processed on the server. Angry Banana's is probably the neatest way of handling what you're doing.


Advertisement