Replace dashes with other text
Mike E.
5 posts
|
I’m trying to replace a dashed line with an answer after a “click here” prompt. Here’s an example: 1) Find the principal parts of the verb “drive” by filling in the blanks below. Click here to check your answer. I _ now. (Present tense) After “Click here” is clicked, the above will be changed to: I drive now. (Present tense) Is there a way to do this with javascript/scriptaculous? I’m building an instuctional site on English grammar. I’d appreciate some help. Thanks, |
Christophe P...
28 posts
|
I’d go gsub with a replacement function and a lexical closure to iterate over an array of answers from one replacement to the next. Say your underscore-bearing HTML is in a
That does the trick neatly :-) |
Mike E.
5 posts
|
Hello Christophe, I realize it’s been a while since I posted this message. I’ve been unavoidably busy and I’m just getting back to this project this week. I tried to implement your suggestion but I wasn’t able to figure out how to set it up properly. Please remember that I’m a javascript ultra-newbie. I have no idea what you mean by “I’d go gsub with a replacement function and a lexical closure to iterate over an array of answers from one replacement to the next.” Sounds good and I’m sure it will work. I’m just not sure how to set it up. Would it be too much to ask if you could walk me through your solution or just show me how to set it up? Thank you so much for your help. Mike |
Christophe P...
28 posts
|
Hey Mike, I put a minimalistic demo page for it up at http://tddsworld.com/questions/ Let me know if that makes it. |
Mike E.
5 posts
|
Thank you so much for the demo. That is just what I need to get me started. I really appreciate your help. Excellent! Mike |
5 posts, 2 voices
