JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 12th, 2001, 01:48 PM
thericksays thericksays is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 2 thericksays User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to thericksays
Passing JavaScript variables in HTML Form

Hello all, this is my first posting here....

In a nutshell, I have some HTML text Fields for First and Last name entry. With those fields I have to create a single Name Variable (which I have), but send that single variable thru my HTML Form. I have tired a number of different approaches, but have been unsuccessful so far.

I have tried setup a function that first validates the entered data, creates the single name variable and returns that variable value, but I have not been able to pick up that value with my HTML Form.

If anyone might be able to give me some direction on how to pick up that JavaScript variable with my HTML, you'd make me a happy camper )

Thanks All

Reply With Quote
  #2  
Old December 12th, 2001, 02:12 PM
mrrichardfeder mrrichardfeder is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2001
Posts: 765 mrrichardfeder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 45 sec
Reputation Power: 12
Guess you must have a reason.

<html>
<head>
</head>
<body>
<div align="center">
<form name="nameTemp">
First Name: <input name="firstName" type="text"><br>
Last Name: <input name="lastName" type="text">
</form>
<form name="mainForm" onsubmit="return singleName(this)">
age: <input name="age" type="text" value="35"><br>
gender: <input name="gender" type="text" value="male"><br>
sex: <input name="sex" type="text" value="yes"><br>
<input name="firstLast" type="hidden">
<input type="submit">
</form>
</div>

<script type="text/javascript">

function singleName(form)
{
if (document.nameTemp.firstName.value == '')
{
alert('Please enter your first name.');
document.nameTemp.firstName.focus();
return false;
}
if (document.nameTemp.lastName.value == '')
{
alert('Please enter your last name.');
document.nameTemp.lastName.focus();
return false;
} else {
form.firstLast.value = document.nameTemp.firstName.value + document.nameTemp.lastName.value;
}
return true;
}

</script>
</body>
</html>

Last edited by mrrichardfeder : December 12th, 2001 at 02:31 PM.

Reply With Quote
  #3  
Old December 17th, 2001, 03:32 PM
thericksays thericksays is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 2 thericksays User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to thericksays
thanks for the example, worked out fine. the reason was my clients wanted two input fields, but the backend data required one field with full name. Thanks, therick

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Passing JavaScript variables in HTML Form

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap