/    Sign up×
Community /Pin to ProfileBookmark

Add one item button

Hi

I have list of checkboxes each one for one team

I need to have a button that add one teacher to one team,

I need add as many teachers as the user needs.

I am using pear quickform

Eg.:
<input type=”hidden” name=”team[][teamcode]” value=”” />
<input name=”team[][teamcode]” type=”checkbox” value=”4610H04178102″ id=”id_d2ff5c” />4110504123102 – ONE TEAM – TEAM:
<input maxlength=”3″ size=”3″ value=”178″ name=”team[][teamnumber]” type=”text” id=”id_team__teamnumber” />
Here comes an add one teacher buttom

How can this be done

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jonathanwkellyJul 23.2010 — What I think would be the best way to do this is to use JavaScript to write in another set of inputs as they use the "add" button. You could use the jQuery .append() method to write in this new markup. You will then have the issue of where to grab the dynamic identifiers from (e.g. "4610H04178102"). You could use the jQuery .ajax() method to query a server-side script to capture these values for you.

http://api.jquery.com/append/

http://api.jquery.com/category/ajax/
Copy linkTweet thisAlerts:
@iahneJul 25.2010 — Try this..

[CODE]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function CreateTextbox() {
var createTextbox = document.getElementById('createTextbox');
var label = document.createElement('label');

label.appendChild(box('txtqty[]'));
document.getElementById('createTextbox').appendChild(label);
}

function box(nameValue) {
var elm = null;
try { // IE
elm=document.createElement('<input type="text" name="'+nameValue+'" id="txtqty" maxlength="5" style="width:100&#37;">');
}
catch(e)
{ // W3C
elm = document.createElement('input');
elm.setAttribute('type', 'text');
elm.name = nameValue;

elm.setAttribute('style',"width:10");
elm.setAttribute('id',"txtqty");
elm.setAttribute('maxlength',"5");
return elm;
}
}
</script>

</head>

<body>

<input type="button" value="clickHere" onclick="CreateTextbox('foobar')">

<div id="createTextbox">
</div>

</body>
</html>
[/CODE]
×

Success!

Help @amrigo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...