[thelist] [js] Adding nodes with incremental numbers

M.G. Noriega manuel at simplelogica.net
Fri Aug 8 04:41:44 CDT 2003

Hi, i've got this script that is a survey-builder. When the user defines
a question, she gets some textareas for every answer, each joined by a
checkbox that indicates 'this is the right answer'; like these four : 

Respuesta correcta (es) = Right Answer (en)

<p class="form"><textarea cols="120" rows="4"
 <input type="checkbox" name="item_opciones_correcta['1']"
class="no"/>Respuesta Correcta</p

<p class="form"><textarea cols="120" rows="4"
 <input type="checkbox"
 class="no" />Respuesta Correcta</p>

<p class="form"><textarea cols="120" rows="4"
 <input type="checkbox"
 class="no" />Respuesta Correcta</p>

<p class="form"><textarea cols="120" rows="4"
 <input type="checkbox"
 class="no" />Respuesta Correcta</p>

Now i want to implement a 'add one more option' link that provides more
textarea/checkbox pairs via DOM as needed. I don't know how to face the
numbers issue. The first time i draw the page with, say, four answers i
can supply via PHP the 'number=5' parameter to the javascript and then
use that to number the new answer. But after that, since i'm not
reloading the page, how do i find out what is the last answer number
(for example, '8') to add the right number ('9')?

Excuse me if my sentences are too convoluted to make any sense and
thanks in advance for any help/suggestion :)  

Manuel González Noriega
Simplelógica, construcción web @ http://simplelogica.net
Logicola es el weblog de Simplelógica http://simplelogica.net/logicola/

More information about the thelist mailing list