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 all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
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

html embedded in javascript...further embedded in html!

  • 14-08-2006 1:46am
    #1
    Registered Users, Registered Users 2 Posts: 1,604 ✭✭✭


    I'm not the best at java or javascript - but I've spent most of today trying to learn the later to help me on a bug I'm trying to fix. The problem is a lack of graceful degradation - if a user comes onto this web page I'm working on, and doesnt have JS enabled in their browser, then goes to press a particular button nothing happens. (basically cos the onclick thing uses a javascript function).

    Now I figured then best was to do this was to make the button invisible to the non-JS enabled peoples (its nothing essential), by defining it between <script> tags. This was all well and good, and I eventually managed to make the button pop up agan and all, but I can't seem to link it to the javascript function anymore. The initial code was:
    <input type="button" value="hide settings" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />
    

    The javascript code I have written for the same button is:
    document.write('<form><input type=button value="Hide Settings" id="windowsettingsbutton" onclick="showhide(windowsettings);"></form>')
    

    I've tried every variation of single and double quotes under the sun, but for some reason the showhide function just isn't working - when the button is clicked nothing happens. I've looked this up too, but feel I'm probably looking in the wrong places. As you may have guessed I'm not a programmer, I'm an engineer, and I'm posting up to see if anyone can point me in the right direction! I don't want an outright answer because it annoys me when people post up simple questions they could have worked out for themselves - but some pointer or a link or two would be great if anyone has any :cool:


Comments

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


    In the first one you have the parameter of the function in inverted commas, in the JavaScript equivalent there are no inverted commas.

    It's been years since I've coded, but isn't that the difference of returning a string and returning a variable?


  • Registered Users, Registered Users 2 Posts: 1,604 ✭✭✭blondie83


    I thought so too, but when I do put 'windowsettings' in apostrophes (as shown just there), in the javascript version, the button completly dissapears on the webpage :confused: This depressed me as it took me a while to get the javascript button in the first place, so i took the commas out!


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


    Is windowsettings a variable or a string?


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


    This function works fine for me on Firefox:

    [PHP]
    <script language="JavaScript">
    function showhide(msg)
    {
    alert(msg)
    }
    </script>


    <script language="JavaScript">
    document.write('<form><input type="button" value="Hide Settings" id="windowsettingsbutton" onclick="showhide(\'windowsettings\');"></form>')
    </script>
    [/PHP]


  • Registered Users, Registered Users 2 Posts: 1,604 ✭✭✭blondie83


    That worked perfectly...I'm trying to figure out how mine went wrong now! Clearly the apostrophes, didn't realise you could use the backslashes like that - ah I've a lot to learn with this! Anyway many thanks for your help Ibid, its greatly appreciated :) Any chance of a name so I can refrence you?

    edit: Just got it from your profile there so you can ignore that!


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


    No problem :). Just another example of how economists are, in fact, the most talented and helpful people on the planet ;).

    And g'way out of your references, don't worry about that :).


Advertisement