I feel like you've asked this before, possibly twice. Deja vu. Here's a fresh solution in case the last one(s) didn't work. Tested in snowman, should work in adventures:
Put this in your JavaScript:
window.getName = window.getName || function (nextPsg) {
var name = $('input#name').val();
name = name.trim();
if (!name) {
name = 'somename';
}
character.name = name;
if (nextPsg && typeof nextPsg === 'string') {
story.show(nextPsg);
}
};
...Where 'somename' is the default name.
Put this in the passage:
<input id='name' />
<a href='javascript:void(0)' onclick='getName("next")'>Confirm</a>
...Where "next" is the name of the passage you want to go to next.
Then, to display the name:
<%= character.name %>
So now let's deal with your code:
[[[B]]
]{.namesubmit} <- what is this? it might be something in adventures or some weird part of snowman, i'm really not sure. i doubt it does what you think it does though
<%
$(.namesubmit).click(if(!character.name == "" || null)
{character.name = 'somename'}); <- there's a number of things wrong here
%>
assuming your other code is working, it should look like this:
<span class='namesubmit'>[[B]]</span>
<%
$('span.namesubmit a').click( function () { // selectors are strings, also, you chould wrap this code in a function, since the click() method accepts functions as arguments, not random code
if (!character.name) { // don't need all that other stuff, also, i think the (!) was an accident?
character.name = 'somename';
}
});
%>