/    Sign up×
Community /Pin to ProfileBookmark

delete multiple text fields based on dropdown

Hi, I’ve done a lot of searching the internet for a solution. I have a simple dropdown with 5 values. I have 3 text boxes with values populated from a mysql database. I’d like to delete/remove the values from all 3 text boxes based on just 1 selection. e.g. the other 4 would do nothing. Can this be done?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PadonakJun 26.2010 — this is just an example


[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>No title</title>
<style type="text/css">
<!--
div#workingarea{text-align:center;padding:50px 20px 20px 20px;}
div#workingarea input{margin-left:10px;margin-right:10px;text-align:center;}
div#displ{text-align:center;}
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function set_elems(){
var sel = document.getElementById("sel");
sel.onchange = function(){
if(this.selectedIndex != 4){this.blur(); return;}
else{
var txts = this.parentNode.getElementsByTagName("INPUT");
for(var i = 0; i < txts.length; i++){txts[i].value = "";}
this.blur();
}
}
document.getElementById("show_val").onclick = show_values;
}

function show_values(){
var displ = document.getElementById("displ");
displ.innerHTML = "";
var txts = this.parentNode.getElementsByTagName("INPUT");
for(var i = 0; i < txts.length; i++){
displ.innerHTML += "textfield " + (i + 1) + " value = " + txts[i].value + "<br />";
}
this.blur();
}

window.onload = set_elems;
//-->
</script>
</head>
<body>
<div id="workingarea">
<select id="sel">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">this will clear the fields</option>
</select>
<br /><br /><br />
<input type="text" size="20" value="10" /><input type="text" size="20" value="20" /><input type="text" size="20" value="30" />
<br /><br />
<a href="#null" id="show_val">show current values</a>
</div>
<br /><br />
<div id="displ">test area</div>
</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@dizzadauthorJun 27.2010 — Hello Padonak, This is perfect, just what I need. I can't thank you enough. Now I can finally move on with this project. Thanks! Jim
Copy linkTweet thisAlerts:
@PadonakJun 27.2010 — glad to hear that it was useful :-) i'm just a plumber and coding is just a hobby for me. i like to help people when i see i can.
×

Success!

Help @dizzad 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.19,
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,
)...