Jump to content
  • Advertisement
Sign in to follow this  
GameMasterXL

[web] javascript and forums

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am creating a script eidtor using javascript, html but i want it so that if you click on different links it calls a different javascript 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.

Share this post


Link to post
Share on other sites
Advertisement
Not sure what you mean, exactly.
To get a hyperlink to call a script function, you can do this:

<a href="javascript:javascript_code_in_here()">Link</a>

(For example, Click!).
If you mean you want to edit the HTML of your page, you can create elements, assign them with an ID then edit their innerHTML property, such as:

THIS IS THE ELEMENT I'M GOING TO CHANGE!

Click to change.

(I had to use an anchor, the forum software doesn't like posting paragraph tags).
If you click "Edit" on my post, you can see the script I used.

Share this post


Link to post
Share on other sites
Nice is whay i am doing is i want the javascript 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.

Share this post


Link to post
Share on other sites
Yes, seeing as you can set the .innerHTML to anything you want. The forum software on this site strips out javascript 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 javascript function to a normal submit button, set the input type to "button" and add a field called onclick which contains the javascript - for example:

<input type="button" onclick="alert('Hello')" value="Click me!" name="test_button" />

I'm not entirely sure what you're asking, though. Sorry...

Share this post


Link to post
Share on other sites
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 javascript 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.

Share this post


Link to post
Share on other sites
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);
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!