How do I implement HTML into Quest?

lightwriter
I'm a bit confused as to how to implement HTML in quest. Specifically, I am trying to implement radio buttons and other form features.

Pertex
This is the perfect question for The Pixie :-)

The Pixie
In a dialogue box like this?
http://textadventures.co.uk/games/view/ ... tcg/deeper

Here is a simple example:
viewtopic.php?f=18&t=4822#p35972

And a library:
viewtopic.php?f=18&t=5474

Also, take a look at this page which explains how to link JavaScript to your game:
http://docs.textadventures.co.uk/quest/ ... cript.html


If you just want radio buttons in the text, just print the HTML:
msg ("Are you  <form><input type=\"radio\" name=\"gender\" value=\"male\" onclick=\"ASLEvent('GenderSelected', 'male');\"> Male<br/><input type=\"radio\" name=\"gender\" value=\"female\" onclick=\"ASLEvent('GenderSelected', 'female');\"> Female</form>")

The onclick event here will invoke the special function ASLEvent, which in turn will call a function in your game called, in this instance, GenderSelected, with the gender as a parameter.

lightwriter
The Pixie wrote:In a dialogue box like this?
http://textadventures.co.uk/games/view/ ... tcg/deeper

Here is a simple example:
viewtopic.php?f=18&t=4822#p35972

And a library:
viewtopic.php?f=18&t=5474

Also, take a look at this page which explains how to link JavaScript to your game:
http://docs.textadventures.co.uk/quest/ ... cript.html


If you just want radio buttons in the text, just print the HTML:
msg ("Are you  <form><input type=\"radio\" name=\"gender\" value=\"male\" onclick=\"ASLEvent('GenderSelected', 'male');\"> Male<br/><input type=\"radio\" name=\"gender\" value=\"female\" onclick=\"ASLEvent('GenderSelected', 'female');\"> Female</form>")

The onclick event here will invoke the special function ASLEvent, which in turn will call a function in your game called, in this instance, GenderSelected, with the gender as a parameter.

That's exactly what I'm trying to do...

lightwriter
What am I doing wrong with trying to make it so when the player selects a gender it reads the value of the radio button checked.

<stuff><![CDATA[
<div id="dialog_window_1" class="dialog_window" title="Character Creation">
<p>Input your character information here!</p>
Name: <input type="text" id="name_input" /><br/>
Age: <input type="text" id="age_input" class="numbersOnly" /><br/>
Gender: <input type="radio" name="gender" id="Male" value="Male">Male<input type="radio" name="gender" id="Female" value="Female">Female<br/>
</div>
<script>
jQuery('.numbersOnly').keyup(function () {
this.value = this.value.replace(/[^0-9\.]/g,'');
});

function setValues() {
answer = $('#name_input').val() + "|" + $('#age_input').val() + "|" + $('input:radio[name=gender:checked').val();
ASLEvent("HandleDialogue", answer);
$('#dialog_window_1').dialog("close");
}

$(document).ready(function () {
$('#dialog_window_1').dialog({
height: 400,
width: 640,
buttons: {
"Done": function() { setValues();}
}
});
});
</script>
]]></stuff>

The Pixie
Create a function in Quest called HandleDialogue that takes a single parameter, (say s) and returns nothing. It will get called by the dialogue, and sent a string like this (it would be worth printing the string to screen to see:

"boris|37|male"

You can use the Split function to break that in to its bits:
msg(s)  // for debugging only
ary = Split(s, "|")
age = ToInt(StringListItem(ary, 2))

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums