Total Java newbie but i know there’s a way to do it.
I would like to create a web page where a user can select a name from a dropdown & the page’s text changes based on that selection.
To explain, if the page says:
[B]Steve likes corn & apples. Steve also likes motorcycles. “I”ve always like grapes”, said Steve.
If a user selects Joe from a drop down option list, it changes to
[B] Joe likes corn & apples. Joe also likes motorcycles. “I”ve always like grapes”, said Joe.
Here’s the drop down list code
<select name=”select” id=”select”>
<option value=”Joe”>Joe</option>
<option value=”Steve”>Steve</option>
</select>
I’m thinking I need some sort of on-click change
Thanks in advance my technical bruthas!?
[code=html]<html>
<head>
<title>New Page 1</title>
<script type="text/javascript">
var aryContent = new Array();
aryContent[0] = "Select a name from the select box above.";
aryContent['Joe'] = "Joe likes corn & apples. Joe also likes motorcycles. "I've always like grapes", said Joe.";
aryContent['Steve'] = "Steve likes corn & apples. Steve also likes motorcycles. "I've always like grapes", said Steve.";
aryContent['Chazzl'] = "Chazzl likes pizza. Chazzl also likes gyrocopters. "I've always like oranges", said Chazzl.";
function updateContent(obj){
var objContent = document.getElementById('contentID');
objContent.innerHTML = aryContent[ obj[obj.selectedIndex].value ];
}
</script>
<style type="text/css">
select{
border:1px solid #B9CDED;
margin-left: 10px;
}
.contentBox{
border:1px solid #B9CDED;
margin: 10px;
padding: 4px;
background-color: #EDEDED;
font: normal 10pt sans-serif;
}
</style>
</head>
<body>
<select name="people" id="peopleID" onchange="updateContent(this);">
<option value="0">Choose a name</option>
<option value="Joe">Joe</option>
<option value="Steve">Steve</option>
<option value="Chazzl">Chazzl</option>
</select>
<div class="contentBox" id="contentID">Select a name from the select box above.</div>
</body>
</html>
[/code]
[code=php]
<html>
<head>
<title>New Page 1</title>
<script type="text/javascript">
var aryContent = new Array();
aryContent[0] = "Select a name and likes from the select boxes above.";
aryContent[1] = "::: likes corn & apples. ::: also likes motorcycles. "I've always like grapes", said :::.";
aryContent[2] = "::: likes pizza. ::: also likes gyrocopters. "I've always like oranges", said :::.";
var Content = aryContent[0];
function updateContent(obj){
var objLikes = document.getElementById('likesID');
var objContent = document.getElementById('contentID');
var Content = aryContent[objLikes[objLikes.selectedIndex].value];
Content = Content.replace(/:::/g,obj);
objContent.innerHTML = Content;
}
function updateLikes(posn){
Content = aryContent[posn];
updateContent(document.getElementById('peopleID').value);
}
</script>
<style type="text/css">
select{
border:1px solid #B9CDED;
margin-left: 10px;
}
.contentBox{
border:1px solid #B9CDED;
margin: 10px;
padding: 4px;
background-color: #EDEDED;
font: normal 10pt sans-serif;
}
</style>
</head>
<body>
<select name="people" id="peopleID" onchange="updateContent(this.value);">
<option value="">Choose a name</option>
<option value="Joe">Joe</option>
<option value="Steve">Steve</option>
<option value="Chazzl">Chazzl</option>
<option value="John">John</option>
<option value="Jacob">Jacob</option>
<option value="Jinglehimer">Jinglehimer</option>
<option value="Smith">Smith</option>
</select>
<select name="people" id="likesID" onchange="updateLikes(this.value);">
<option value="0" checked>Choose a like</option>
<option value="1">Motorcycles</option>
<option value="2">Pizza</option>
</select>
<div class="contentBox" id="contentID">Select a name and likes from the select boxes above.</div>
</body>
</html>
[/code]
[code=php]
<html>
<head>
<title>New Lyrics</title>
<script type="text/javascript">
var lyrics =
":::, you come and ask me girl<br>"+
"To set you free, girl<br>"+
"You say he loves you more than me<br>"+
'<br>'+
"So I will set you free<br>"+
"Go with him, go with him<br>"+
'<br>'+
":::, girl, before you go now<br>"+
"I want you to know now<br>"+
"That I still love you so<br>"+
"But if he loves you more, go with him<br>"+
'<br>'+
"All of my life I've been searching for a girl<br>"+
"To love me like I love you oh, now<br>"+
"But every girl I've ever had breaks my heart<br>"+
'<br>'+
"And leaves me sad, what am I<br>"+
"What am I suppose to do oh, oh, oh .....<br>"+
":::, just one more thing, girl<br>"+
"You give back your ring to me<br>"+
"And I will set you free, go with him<br>"+
'<br>'+
"All of my life I've been searching for a girl<br>"+
"To love me like I love you<br>"+
"Cause let me tell you now<br>"+
"But every girl I've ever had breaks my heart<br>"+
'<br>'+
"And leaves me sad, what am I<br>"+
"What am I suppose to do oh, oh, oh .....<br>"+
":::, just one more thing, girl<br>"+
"You give back your ring to me<br>"+
"And I will set you free,<br>"+
"Go with him, go with him<br>"+
"You can go with him, girl, go with him";
var Content = lyrics;
function updateContent(obj){
Content = lyrics;
var objContent = document.getElementById('contentID');
Content = Content.replace(/:::/g,obj);
objContent.innerHTML = Content;
}
</script>
<style type="text/css">
select{
border:1px solid #B9CDED;
margin-left: 10px;
}
.contentBox{
border:1px solid #B9CDED;
margin: 10px;
padding: 4px;
background-color: #EDEDED;
font: normal 10pt sans-serif;
width: 400px;
}
</style>
</head>
<body>
<select name="people" id="peopleID" onchange="updateContent(this.value);">
<option value="">Choose a name</option>
<option value="Anna">Anna</option>
<option value="Betty">Betty</option>
<option value="Chazzl">Chazzl</option>
<option value="Diana">Diana</option>
<option value="Elizabeth">Elizabeth</option>
<option value="Francis">Francis</option>
<option value="Heather">Heather</option>
</select>
<div class="contentBox" id="contentID">Select a name and likes from the select boxes above.</div>
</body>
</html>
[/code]
I’m in a girl song, ewwww ? j/k hehe[/quote]
[code=php]
<input type="text" id="Name1" value="">
<input type="text" id="Name2" value="">
[/code]
[code=php]
function updateContent(obj1,obj2){
Content = lyrics;
var objContent = document.getElementById('contentID');
Content = Content.replace(/::1::/g,obj1);
Content = Content.replace(/::2::/g,obj2);
objContent.innerHTML = Content;
}
[/code]
[code=php]
<button onclick="updateContent(document.getElementById('Name1').value,document.getElementById('Name2').value)">
Change</button>
[/code]
[code=php]
<html>
<head>
<title> </title>
<script type="text/javascript">
function LinkToChoice(where) {
if (where == 'Selection') { alert('Need a '+where); return; }
// following to replace alert when 'where' is defined
// document.location.href=where;
alert('Go to: '+where);
}
</script>
</head>
<body>
<select id="choices" onchange="LinkToChoice(this.value)">
<option value="Selection">Selection</option>
<option value="www.blah.com/billy.mp3">Billy</option>
<option value="www.blah.com/bob.mp3">Bob</option>
</select>
</body>
</html>
[/code]
[code=php]
Name: ::: - <img src="Pics/Listen.png" width="21" height="25">
<a href="www.whatever.com/:::.mp3">Click here to listen</a>
<br>
- <img src="Pics/Download.png" width="21" height="25">
<a href="www.whatever.com/:::.mp3">Click here to download</a> ;
[/code]
[code=php]
<html>
<head>
<title>Song Downloads</title>
<script type="text/javascript">
var lyrics = '';
lyrics += 'Name: ::: <br>- <img src="Pics/Listen.png" width="21" height="25" alt="Listen to Demo">';
lyrics += ' <a href="www.whatever.com/:::.mp3">Click here to listen</a>';
lyrics += '<br>- <img src="Pics/Download.png" width="21" height="25" alt="Download music">';
lyrics += ' <a href="www.whatever.com/:::.mp3">Click here to download</a>';
var Content = lyrics;
function updateContent(obj){
Content = lyrics;
var objContent = document.getElementById('contentID');
Content = Content.replace(/:::/g,obj);
objContent.innerHTML = Content;
}
</script><style type="text/css">
select{
border:1px solid #B9CDED;
margin-left: 10px;
}
.contentBox{
border:1px solid #B9CDED;
margin: 10px;
padding: 4px;
width: 300px;
font: normal 10pt Verdana;
} </style>
<select id="peopleID" onchange="updateContent(this.value);" name="people">
<option value="" selected="selected">Choose a name</option>
<option value="Billy">Billy</option>
<option value="Chazzl">Chazzl</option>
<option value="Heather">Heather</option>
<option value="Jennifer">Jennifer</option>
<option value="Jessica">Jessica</option>
<option value="Karen">Karen</option>
<option value="Linda">Linda</option>
<option value="Lisa">Lisa</option>
<option value="Melissa">Melissa</option>
<option value="Michelle">Michelle</option>
<option value="Susan">Susan</option>
</select>
</p>
<div class="contentBox" id="contentID">
Select a name from the select boxes above.
</div>
</body>
</html>
[/code]
<html>
<head>
<title>Song Downloads</title>
<script type="text/javascript">
var namelinks = '';
namelinks += 'Name: ::1 <br>- <img src="Pics/Listen.png" width="21" height="25" alt="Listen to Demo">';
namelinks += ' <a href="www.whatever.com/::1.mp3">Click here to listen</a>';
namelinks += '<br>- <img src="Pics/Download.png" width="21" height="25" alt="Download music">';
namelinks += ' <a href="www.whatever.com/::1.mp3">Click here to download</a>';
var Content = namelinks;
function updateContent(obj){
Content = namelinks;
var objContent = document.getElementById('LinkBox');
Content = Content.replace(/::1/g,obj);
objContent.innerHTML = Content;
}
</script>
<select id="peopleID" onchange="updateContent(this.value);" name="people">
<option value="" selected="selected">Choose a name</option>
<option value="Billy">Billy</option>
<option value="Chazzl">Chazzl</option>
<option value="Heather">Heather</option>
<option value="Jennifer">Jennifer</option>
<option value="Jessica">Jessica</option>
<option value="Karen">Karen</option>
<option value="Linda">Linda</option>
<option value="Lisa">Lisa</option>
<option value="Melissa">Melissa</option>
<option value="Michelle">Michelle</option>
<option value="Susan">Susan</option>
</select>
</p>
<div class="contentBox" id="LinkBox">
Select a name from the select boxes above.
</div>
<script type="text/javascript">
var lyrics =
"Sweet little girl, she comes right to me<br />"+
"My little <b>:::</b>.";
var Content = lyrics;
function updateContent(obj){
Content = lyrics;
var objContent = document.getElementById('ContentID');
Content = Content.replace(/:::/g,obj);
objContent.innerHTML = Content;
}
</script>
<p>
<select id="nameID" onChange="updateContent(this.value);" name="names">
<option value="">Select Name</option>
<option value="Angela">Angela</option>
<option value="Ashley">Ashley</option>
<option value="Brittney">Brittney</option>
<option value="Christie">Christie</option>
<option value="Christine">Christine</option>
<option value="Debra/Deborah">Debra/Deborah</option>
<option value="Donna">Donna</option>
<option value="Emily">Emily</option>
<option value="Heather">Heather</option>
<option value="Jennifer">Jennifer</option>
<option value="Jessica">Jessica</option>
<option value="Karen">Karen</option>
<option value="Laura">Laura</option>
<option value="Linda">Linda</option>
<option value="Lisa">Lisa</option>
<option value="Lori">Lori</option>
<option value="Melissa">Melissa</option>
<option value="Michelle">Michelle</option>
<option value="Rachel">Rachel</option>
<option value="Stephanie">Stephanie</option>
<option value="Susan">Susan</option>
<option value="Suzy">Suzy</option>
</select>
</p>
<div class="contentBox" id="contentID">
Select a name from the select boxes above.
</div>
</body>
</html> [/QUOTE]
[code=php]
<html>
<head>
<title>Song Downloads</title>
<script type="text/javascript">
var namelinks = '';
namelinks += 'Name: ::1 <br>- <img src="Pics/Listen.png" width="21" height="25" alt="Listen to Demo">';
namelinks += ' <a href="www.whatever.com/::1.mp3">Click here to listen</a>';
namelinks += '<br>- <img src="Pics/Download.png" width="21" height="25" alt="Download music">';
namelinks += ' <a href="www.whatever.com/::1.mp3">Click here to download</a>';
var Content1 = '';
function updateContent1(obj){
Content1 = namelinks;
var objContent = document.getElementById('LinkBox');
Content1 = Content1.replace(/::1/g,obj);
objContent.innerHTML = Content1;
}
var lyrics =
"Sweet little girl, she comes right to me<br />"+
"My little <b>:::</b>.";
var Content2 = '';
function updateContent2(obj){
Content2 = lyrics;
var objContent = document.getElementById('ContentID');
Content2 = Content2.replace(/:::/g,obj);
objContent.innerHTML = Content2;
}
</script>
</HEAD>
<BODY>
<select id="peopleID" onchange="updateContent1(this.value);" name="people">
<option value="" selected="selected">Choose a name</option>
<option value="Billy">Billy</option>
<option value="Chazzl">Chazzl</option>
<option value="Heather">Heather</option>
<option value="Jennifer">Jennifer</option>
<option value="Jessica">Jessica</option>
<option value="Karen">Karen</option>
<option value="Linda">Linda</option>
<option value="Lisa">Lisa</option>
<option value="Melissa">Melissa</option>
<option value="Michelle">Michelle</option>
<option value="Susan">Susan</option>
</select>
</p>
<div class="contentBox" id="LinkBox">Select a name from the select boxes above.</div>
<p>
<select id="nameID" onChange="updateContent2(this.value)" name="names">
<option value="">Select Name</option>
<option value="Angela">Angela</option>
<option value="Ashley">Ashley</option>
<option value="Brittney">Brittney</option>
<option value="Christie">Christie</option>
<option value="Christine">Christine</option>
<option value="Debra/Deborah">Debra/Deborah</option>
<option value="Donna">Donna</option>
<option value="Emily">Emily</option>
<option value="Heather">Heather</option>
<option value="Jennifer">Jennifer</option>
<option value="Jessica">Jessica</option>
<option value="Karen">Karen</option>
<option value="Laura">Laura</option>
<option value="Linda">Linda</option>
<option value="Lisa">Lisa</option>
<option value="Lori">Lori</option>
<option value="Melissa">Melissa</option>
<option value="Michelle">Michelle</option>
<option value="Rachel">Rachel</option>
<option value="Stephanie">Stephanie</option>
<option value="Susan">Susan</option>
<option value="Suzy">Suzy</option>
</select>
</p>
<div class="contentBox" id="ContentID">Select a name from the select boxes above.</div>
</body>
</html>
[/code]
I have a much simpler task related to this....
I want to have a blank box... with a text form field below it (1 line, limited to 140 characters in length), with a pretyped text (value) already inserted which changes a certain string based on what the visitor types in the blank box above.... it'd look like this.....
[ENTER TEXT HERE]
SUBMIT BUTTON
Sally has a *** that likes to eat
Then whatever the user types in the box ENTER TEXT HERE and then hits the submit button and it will replace *** with whatever they typed......
For example
[Cat]
(presses submit button)
Sally has a Cat that like to eat
Any suggestions?[/QUOTE]
0.1.9 — BETA 5.27