/    Sign up×
Community /Pin to ProfileBookmark

Urgent Help for something simple

Hello All,

So I am having some issues with something that seems absolutely easy and simple but it is giving me a very hard time.

I need a single web page with some text, a few numeric text boxes, and a “next” button.
The thing is that I need to have a person fill in the text boxes with some numbers and depending on the numbers entered, the link on the “next” button should change.
Any ideas of how I could do this?

Thanks a bunch!!!

to post a comment
JavaScript

13 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJun 11.2009 — Post your 'simple' attempt and we'll see if it is possible.
Copy linkTweet thisAlerts:
@Rufe0Jun 11.2009 — we need more information like what math is involved?
Copy linkTweet thisAlerts:
@swayauthorJun 11.2009 — well the math is that if the first number is 0, it will be one link for the "next" button, if the second number is 0, it will be another link and so on until i m left with no text boxes. nothing more than that
Copy linkTweet thisAlerts:
@Rufe0Jun 11.2009 — ah i think i might know what your on about now.

do you want to only submit your form if the user has inputted a value into all of the textboxes?
Copy linkTweet thisAlerts:
@JMRKERJun 11.2009 — To repeat ... ?
Post your 'simple' attempt and we'll see if it is possible.[/QUOTE]
Copy linkTweet thisAlerts:
@swayauthorJun 11.2009 — ah i think i might know what your on about now.

do you want to only submit your form if the user has inputted a value into all of the textboxes?[/QUOTE]


well kind of

i need to check if they have entered 0 or left blank any of the textboxes,

and if they have, i need to redirect them to a specific link, if not i need to redirect them to a different link

my biggest problem is that i can't figure out how to take in the input. As soon as i have the input from the different textboxes stored in different variables then i can have an if-else to check what i am looking for, but i am having troubles reading it in.

And also after i have built the if-else, the other problem is that i am not exactly sure how i can change the link i redirect them to.

thanks a bunch for the help!!!
Copy linkTweet thisAlerts:
@CodericJun 12.2009 — To repeat ... ?

Quote:

Originally Posted by JMRKER


Post your 'simple' attempt and we'll see if it is possible. [/QUOTE]


Sway ! JMRKER has requested that you actually show your code, it will most assuredly help you to a quicker solution. ?
Copy linkTweet thisAlerts:
@swayauthorJun 12.2009 — i worked on this a bit more and this is what i have. (all the names and so on are pretty random but i guess you can still get the idea.)

but i m not sure how well it would work eventually because i need to add a few other things.

one extra thing that i need to add is that i need to check the total sum of the numbers from the input and see if it is less than 50, or else return an error and ask for other input.


<!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 MM_getURL() {

var val1, val2, num1, num2, args=MM_getURL.arguments; document.MM_returnValue = false;

for (i=0; i<(args.length-1); i+=3){

val1=document.getElementById(args[i+1]);

val2=document.getElementById(args[i+2]);

num1=parseFloat(val1.value);

num2=parseFloat(val2.value);

if (num1==0) eval(args[i]+".location.href='http://www.nytimes.com/'");

else

if (num2==0) eval(args[i]+".location='Untitled-3.html'");

else

eval(args[i]+".location='Document.html'");

}

}

//-->

</script>

</head>



<body>

<p>text</p>

<form id="form1" name="form1" method="post" action="">

<label>op One

<input name="op1" type="text" id="op1" maxlength="2" />

</label>

<p>

<label>op two

<input name="op2" type="text" id="op2" maxlength="2" />

</label>

</p>

<p>

<label>

<input name="submit" type="submit" id="submit" onclick="MM_getURL('parent','op1','op2');return document.MM_returnValue" value="Submit" />

</label>

</p>

</form>



</body>

</html>
Copy linkTweet thisAlerts:
@Rufe0Jun 12.2009 — are you sure you dont want to just pop up a message to user saying somthing like "you must fill in the number boxes"?
Copy linkTweet thisAlerts:
@swayauthorJun 15.2009 — well that could work too, but how could i do it?
Copy linkTweet thisAlerts:
@Rufe0Jun 16.2009 — [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title></title>

<script language="JavaScript" type="text/javascript">
function checkform(){
var one = document.getElementById('text1').value * 1;
var two = document.getElementById('text2').value * 1;
if(isNaN(one)||isNaN(two)){
document.getElementById('label1').innerHTML = "You Must enter a Number in both boxes!";
alert("You Must enter a Number in both boxes!");
}else{
alert(one + " - " + two);
//document.form1.submit();
}
}
</script>

</head>

<body>
<form name="form1" id="form1" action="somewhere.html" method="post">
<label name="label1" id="label1"></label><br>
<input name="text1" id="text1" type="text" /><br>
<input name="text2" id="text2" type="text" /></td>
<br>
<a href="javascript: checkform()">Submit</a>
</form>
</body>

</html>
[/CODE]
Copy linkTweet thisAlerts:
@Rufe0Jun 16.2009 — Sorry i mean this
[CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title></title>

<script language="JavaScript" type="text/javascript">
function checkform(){
var one = document.getElementById('text1').value * 1;
var two = document.getElementById('text2').value * 1;
if(isNaN(one)||isNaN(two)){
document.getElementById('label1').innerHTML = "You Must enter a Number in both boxes!";
alert("You Must enter a Number in both boxes!");
}else{
document.form1.submit();
}
}
</script>

</head>

<body>
<form name="form1" id="form1" action="somewhere.html" method="post">
<label name="label1" id="label1"></label><br>
<input name="text1" id="text1" type="text" /><br>
<input name="text2" id="text2" type="text" /></td>
<br>
<a href="javascript: checkform()">Submit</a>
</form>
</body>

</html>[/CODE]
Copy linkTweet thisAlerts:
@swayauthorJun 17.2009 — thanks a bunch!!

it all worked out perfectly
×

Success!

Help @sway 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.16,
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,
)...