jQuery add

Gestart doorBartv0 reacties26 weergaven

1 berichten · pagina 1 van 1

Bartv

Lid · Topicstarter

Berichten
4.451
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kan dicht
toevoeging op 11 juni 2012, 15:23:42:
Gefixt heb het nu zo:

<div id="titel2">Solicitatie aanmaken</div>
<div id="midden2" >
<script>

$(function() { // when document has loaded

    var i = $(input#v).size() + 1; // check how many input exists on the document and add 1 for the add command to work

    $(a#add).click(function() { // when you click the add link
        $(<tr id="v + i + "><td><strong>Vraag  + i + </strong></td><td><input type="text" name="v + i +" id="v" /></td></tr>).appendTo(table#1); // append (add) a new input to the document.
// if you have the input inside a form, change body to form in the appendTo
        i++; //after the click i will be i = 3 if you click again i will be i = 4
    });

    $(a#remove).click(function() { // similar to the previous, when you click remove link
    if(i > 1) { // if you have at least 1 input on the form
        $(input:last).remove(); //remove the last input
        i--; //deduct 1 from i so if i = 3, after i--, i will be i = 2
    }
    });

    $(a.reset).click(function() {
    while(i > 2) { // while you have more than 1 input on the page
        $(input:last).remove(); // remove inputs
        i--;
    }
    });

});
</script>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//if(rang($_SESSION["naam"]) == "Admin"){[/COLOR]
    
?>
<form name="solia" method="POST">
<table id="1">
    <tr>
        <td width="100px"><strong>Titel:</td><td width="100px"><input type="text" name="titel" /></strong></td>
    </tr>
    <tr>
        <td><strong>Tekst: (waarvoor ze soliciteren)</strong></td>
        <td><textarea name="tekst" cols="50" rows="10"></textarea></td>
    </tr>
    <tr>
        <td><strong>Vraag 1:</strong></td><td><input type="text" name="v1" id="v" /></td><td><select name="v1s"><option value="1">Tekst vak</option><option value="2">Tekst area</option></select></td>
    </tr>
    <tr>
        <td><strong>Vraag 2:</strong></td><td><input type="text" name="v2" id="v" /></td><td><select name="v2s"><option value="1">Tekst vak</option><option value="2">Tekst area</option></select></td>
    </tr>
</table>
<table id="2">
    <tr>
        <td><a id="add"><img src="afbeeldingen/plus.png" width="15px" height="15px" alt="Plus" /></a></td>
    </tr>
    <tr>
        <td><strong>Status?</strong></td><td>
            <select name="status">
                <option value="1">Geopend</option>
                <option value="0">Gesloten</option>
                <option value="2">Onzichtbaar</option>
            </select>
        </td>
    </tr>
    <tr>
        <td><input type="submit" name="submit" value="Maken" /></td>
    </tr>
</table>
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//}
//else
//{
//echoJe bent niet bevoegd om hier te komen;
//}[/COLOR]
?>
<div style="clear:both;"></div>
</div>
<div id="einde2" ></div>
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren