Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

small coding troubles with and variables

i'm seeming to be having problems with <<replace>>... this is only my second day with the program so do bear with me ^^
the following is my coding in the first passage:

[06:29:11 PM] <b>ADMIN</b>: I'm...
<<textbox "$name" "" "Sent message">>
<subscript>Hit ENTER to send.</subscript>

and the following in the coding in the second passage:

[06:29:11 PM] <b>ADMIN</b>: I'm... <span id="playername">name</span>.
<<replace "#playername">><<print $name>><</replace>>

whenever i try to do this it gives me the error saying, "Error: <<replace>>: no elements matched the selector "#name"". i'm not quite sure what i'm doing wrong, so would someone care to correct this?

Comments

  • First. Please specify which story format you're using. Based on your examples, I'm going to assume SugarCube 1.x.

    Second. Please place example code within code blocks (C on the bar).


    You cannot target elements within the same passage with the DOM macros, since they don't exist as a part of the DOM (page) yet, which is because the passage is still rending. You're putting the cart before the horse, as it were.

    Beyond that, and going by your examples, this doesn't seem to be a place where you need to use <<replace>> in the first place. Is there any reason why you aren't simply printing $name in your second passage? For example:
    [06:29:11 PM] <b>ADMIN</b>: I'm... <<print $name>>.
    
  • ahh i'm sorry, yes i am using sugarcube 1.x.
    i suppose i was reading in on it too much-- the code you gave me worked. i was trying to read info on interactive macros and for some reason thought i needed the <<replace>> thanks for the help, sorry for the trouble!
Sign In or Register to comment.