[web] javascript and forums

Started by
20 comments, last by GameMasterXL 18 years, 7 months ago
I am creating a script eidtor using &#106avascript, html but i want it so that if you click on different links it calls a different &#106avascript function that will create a html UI with the required events on it in a certain place on my page is this possible? if so how would one go about doing it? thanks.
Advertisement
Not sure what you mean, exactly.
To get a hyperlink to call a script function, you can do this:

<a href="&#106avascript:&#106avascript_code_in_here()"&gt;Link&lt;/a&gt;</tt><br><br>(For example, <a href="&#106avascript:alert('Click EDIT &#111;n my post to see how I did this.')">Click!</a>).<br>If you mean you want to edit the HTML of your page, you can create elements, assign them with an ID then edit their <tt>innerHTML</tt> property, such as:<br><br><a id="changer">THIS IS THE ELEMENT I'M GOING TO CHANGE!</a><br><br><a href="&#106avascript:document.getElementById('changer').innerHTML='<b>I am the new stuff.</b>';void(0)">Click to change.</a><br><br>(I had to use an anchor, the forum software doesn't like posting paragraph tags).<br>If you click "Edit" &#111;n my post, you can see the script I used.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

omG? That's amazing.

How are you?
Quote:Original post by Pipo DeClown
omG? That's amazing.

How are you?

You need to escape your single quote. [smile]

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Nice is whay i am doing is i want the &#106avascript function to create a UI like buttons and fields that i need with the functions applied to them and the UI gets built on my html page were i want them to go. Is it possible.
Yes, seeing as you can set the .innerHTML to anything you want. The forum software on this site strips out &#106avascript or form elements pretty harshly (as you'd expect it to!) so I could not write a demo that added, for example, a submit button.

If you want to attach a &#106avascript function to a normal submit button, set the input type to "button" and add a field called <tt>onclick</tt> which contains the &#106avascript - for example:<br><br><tt>&lt;input type="button" &#111;nclick="alert('Hello')" value="Click me!" name="test_button" /&gt;</tt><br><br>I'm not entirely sure what you're asking, though. Sorry...

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Sorry about my vage explanation i will try explain best i can. Is what i am creating is a script editor and in the editor i have a library of commands and for each command i want it so when you click on the link for the command like + command it will create a UI under my text area with the required fields for the user to fill in and then the functions are applied to these controls that will output the value to the main window. So each command has its own unique interface and i want &#106avascript to build the forum in the place i want it to and add the functions to it like creat a text fiel with a button when you press on a link in a specified location.
Ah, right. Sounds like a pretty awkward thing to have to write...
I know they're not as slick, but have you considered using prompt() boxes to get user input?
Example
var x = prompt('Enter your variable below:','Enter it here!');if (x===null) {    alert('Cancelled!');} else {    alert(x);}

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

It wouldn't work for my implimentation. Could i use the innerHtml to create the forums? thanks for your help upto now.
You can use innerHTML to edit any HTML on the page, so adding a few form and input elements on a page is not that much of a challenge. It might be more practical to stick the forms inside div elements and show/hide the divs as needed, though.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

This topic is closed to new replies.

Advertisement