/    Sign up×
Community /Pin to ProfileBookmark

Show Hidden Submit Button IF input matches value

Hi there,

I hope someone can help, I am stuck with my code: [url]http://jsfiddle.net/old_blueyes/JELCK/[/url]

Currently my code is largely working the way in envisage apart from one part.

At the moment I have if you click the Try It button I have random quotes appear in textboxes now what quotes appear depends on a hidden value which i have set.

Now what I wish for is that if one of those textboxes displays a certain quote i.e. if MEDIUM is displayed then it shows a hidden Submit button so I can process the form.

I’ve had a couple of attempts myself but haven’t really got anywhere.

My latest attempt is at the bottom of code within the link posted above.

Cheers

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@vwphillipsNov 24.2012 — [CODE]<!DOCTYPE html>
<html>
<body>

<h2>Java Test</h2>

<button onclick="myFunction(); update();">Try it</button>

<input type="hidden" id="age" value="18"/>

<textarea id="agebox" style="width:150px;" readonly="readonly"></textarea>

<textarea id="prcbox" style="width:150px;" readonly="readonly" onchange="submitChange()"></textarea>

<input type="submit" id="submit" style="display: none;" />


<script>
function myFunction() {
var age,voteable;
age=document.getElementById("age").value;
voteable=(age<18)?"Too young":"Old enough";
document.getElementById("agebox").value=voteable;
}

function update() {
var msg = 'Invalid entry';
var age=document.getElementById("age").value;
if ((age > 0) && (age <= 10)) { msg = 'EASY'; }
if ((age > 10) && (age <= 20)) { msg = 'MEDIUM'; }
if ((age > 20) && (age <= 30)) { msg = 'HARD'; }
document.getElementById("prcbox").value=msg;
submitChange();
}


function submitChange()
{
var inputOne = document.getElementById("prcbox");
var inputSubmit = document.getElementById("submit");
if(inputOne.value == "MEDIUM")
{
inputSubmit.style.display = "block";
}
else
{
inputSubmit.style.display = "none";
}
}

</script>


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

Success!

Help @rbrown 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...