Go Back   nV News Forums > Software Forums > Software Development

Newegg Daily Deals

Reply
 
Thread Tools
Old 11-20-08, 07:09 PM   #13
jcrox
Mahna Mahna
 
jcrox's Avatar
 
Join Date: Jul 2006
Location: Madison, Wi
Posts: 6,134
Default Re: Need some help making medical website

For checking to make sure form fields are filled in I usually use JavaScript.

example:

<html>
<head><title>Form Validation Example</title>
<script language="JavaScript">

function checkField1() {
var valid = true;
var value = document.getElementById("field1").value;
if(value == "" || value == null) {
alert("You didn't enter a value in Field 1");
valid = false;
}
return valid;
}

function checkField2() {
var valid = true;
var value = document.getElementById("field2").value;
if(value == "" || value == null) {
alert("You didn't enter a value in Field2");
valid = false;
}
return valid;
}


function validateForm() {
var valid = true;
valid = checkField1() && checkField2();
return valid;
}
</script>
</head>

<body>
<form method="post" onSubmit="validateForm();">
<input type="text" name="field1" id="field1" />
<input type="text" name="field2" id="field2" />
<input type="submit" value="submit" />
</form>
</body>
</html>
__________________

Gaming

MSI MPower Z87 | 4770k | CNPS9900MAX-B | 8GB G.Skill 1866 | EVGA GTX760 |ThermalTake 850w | X-Fi Titanium | HAF | Asus PA248Q | Lycosa | Death Adder | Win8 Pro 64

Dev/Backup

MSI GD65 | 2500k | H50 | 8GB G.skill | GTX570 | Ubuntu 13.10

Laptop

17" Inspiron | i5 | 4GB DDR3 | 500GB HDD | Win7 Pro 64

jcrox is offline   Reply With Quote
Old 11-20-08, 09:01 PM   #14
ViN86
 
Join Date: Mar 2004
Posts: 15,486
Default Re: Need some help making medical website

i prefer server-side validation, but that will work too

tbh, if i were doing this project, id add a database to keep track of who submitted the form.
ViN86 is offline   Reply With Quote
Old 11-20-08, 10:19 PM   #15
jcrox
Mahna Mahna
 
jcrox's Avatar
 
Join Date: Jul 2006
Location: Madison, Wi
Posts: 6,134
Default Re: Need some help making medical website

Quote:
Originally Posted by ViN86 View Post
i prefer server-side validation, but that will work too

tbh, if i were doing this project, id add a database to keep track of who submitted the form.
I prefer the server side too, especially php... but I was thinking the JavaScript might be a quicker and easier fix if he's not wanting to install Apache and PHP.
__________________

Gaming

MSI MPower Z87 | 4770k | CNPS9900MAX-B | 8GB G.Skill 1866 | EVGA GTX760 |ThermalTake 850w | X-Fi Titanium | HAF | Asus PA248Q | Lycosa | Death Adder | Win8 Pro 64

Dev/Backup

MSI GD65 | 2500k | H50 | 8GB G.skill | GTX570 | Ubuntu 13.10

Laptop

17" Inspiron | i5 | 4GB DDR3 | 500GB HDD | Win7 Pro 64

jcrox is offline   Reply With Quote
Old 11-21-08, 10:25 AM   #16
fivefeet8
Ngemu Mod
 
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: Need some help making medical website

You can also use javascript/CSS to hide parts of the form until certain elements are clicked. For example, lets say you have a checkbox that if clicked will show a selection element.

javascript:
Code:
function showOptions(){

  var box = document.getElementById('cbox');
  var sel = document.getElementById('slbox);

  if(box.checked == true){
    sel.style.display = 'block';    // show element
  }else{
    sel.style.display = 'none';    // hide element
  }
}
html:
Code:
<form name='form' action=''>


  <input id='cbox' type='checkbox' name='cbox' onClick='showOptions();'></input><br />
  <select id='slbox' name='slbox' style='display:none;'>
  <option value='blue'>Blue</option>
  <option value='green'>Green</option>
  </select>
</form>
The hidden select menu will be hidden or shown depending on the status of the checkbox.
__________________
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]
fivefeet8 is offline   Reply With Quote
Old 11-21-08, 01:45 PM   #17
ViN86
 
Join Date: Mar 2004
Posts: 15,486
Default Re: Need some help making medical website

Quote:
Originally Posted by jcrox View Post
I prefer the server side too, especially php... but I was thinking the JavaScript might be a quicker and easier fix if he's not wanting to install Apache and PHP.
WAMP takes care of that
ViN86 is offline   Reply With Quote
Old 11-26-08, 12:05 PM   #18
npras42
Hi Everybody!
 
npras42's Avatar
 
Join Date: Jun 2004
Location: Manchester, UK
Posts: 1,698
Default Re: Need some help making medical website

Ok. Thanks again everyone. I've been like super-busy the last week and a half, but I'm gonna get round to completing this weekend. Gladly, I seem to at least understand the examples given and that's all I need really. I'll check back on Sunday and see what you guys think...
npras42 is offline   Reply With Quote
Reply


Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making Progress: Tribes Ascend's Accelerate Update News Archived News Items 0 06-12-12 07:30 AM
Neal Stephenson's Making A Game, Called CLANG News Gaming Headlines 0 06-10-12 02:10 AM
8 million leaked passwords connected to LinkedIn, dating website News Archived News Items 0 06-06-12 01:50 PM
John Carmack is making a virtual reality headset, $500 kits available soon, video int News Archived News Items 0 06-06-12 09:30 AM

All times are GMT -5. The time now is 01:48 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.