If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2

Thread: form help

  1. #1
    Member fortm's Avatar
    Join Date
    Jul 2011
    Member #
    function show(obj) {
        no = obj.options[obj.selectedIndex].value;
        count = obj.options.length;
        for (j=1;j<=count;j++)
    function validate(id)
    var x1=document.forms["myForm1"]["firstname"].value;
    if (id ==1 && (x1==null || x1==""))
      document.getElementById('error1').innerHTML='First name, form 1 must be filled out';
      return false;
    var x1=document.forms["myForm2"]["firstname"].value;
    if (id ==2 && (x1==null || x1==""))
      document.getElementById('error2').innerHTML='First name , form 2 must be filled out';
      return false;
    HTML Code:
    <div><select onchange="show(this)" size="1">
                                            <option value="1" selected="selected">first</option>
                                            <option value="2">second</option>
      <div id="error1"></div>
      <div id="error2"></div>
      <div id="profile1"  onsubmit="return validate(1)"  style="display: block;">
          <form name="myForm1">
                From 1 First name: <input type="text" name="firstname" /><br />
                From 1 Last name: <input type="text" name="lastname" /><br/>
                <input type="submit" value="Submit" />
      <div id="profile2" onsubmit="return validate(2)" style="display:none;">
          <form name="myForm2">
                From 2 First name: <input type="text" name="firstname" /><br />
                From 2 Last name: <input type="text" name="lastname" /><br />
                <input type="submit" value="Submit" />
    From the above codes, I am making a drop down system to alternate between some forms. But, I am not able to save one form , when I go to another. Also error are not very user friendly. Need to show them as an overlay. Please assist on how to achieve this. I am new to JS and I am using PHP language.

    Also press on submit takes to first form, need to stay in same form when it is submitted successfully or with failure.


  3. #2
    Junior Member SimplyWebsites's Avatar
    Join Date
    Jul 2012
    Member #
    If you want it to submit both parts of the form then you need to wrap the form tags around everything. Of maybe use AJAX for this.

    Just a notce you have onsubmit="return validate(2)" on the div tag, i would have thought this was supposed to be in the form tag, although i have no idea whats its doing.

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 01:13 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: