Solved

Select Field Determines Other Fields

Posted on 2009-04-06
4
185 Views
Last Modified: 2012-05-06
I need a web form that has variable input fields based on a "Select" option.  I imagine that JavaScript is ideal.  I am out of practice on web development skills, and JavaScript was a weak spot.

The Select will have several options:
      Dispense
      Receive
      Return
      Reconcile
When you select "Dispense" I need text fields named:
      Name
      Center
      Number
If you chose "Receiving" text fields appear named:
      Vendor
      Form #
      Invoice #
In the perfect situation each text field is uniquely named verses using the same text fields with different labels.  Some options may need 4 text fields, and another may need 1 field.
In the SQL database I'd have columns named:
   DispName, DispCenter, DispNumber, RecVendor, RecForm, RecInvoice, etc.

I know I've had this in the past, but all my web development code has been lost over time.  I am awarding 500 pts, as this little issue is holding up a database project, and I don't have time to buy a book and learn JavaScript.
0
Comment
Question by:antcal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 5

Accepted Solution

by:
P_Ramprathap earned 500 total points
ID: 24083739
Please try this approach
1. Please have all the controls in the page , please enlose the control and their respective validation control inside a seprate panel
2. on Page load call the function LoadControls ( can be any name of ur choice)
3. based on the Select option you can hide the panel and controls ,. please make sure ur disabling the respective validation controls
4. on Form submition , please pass on relevenat values , and pass default values for hidden controls .
Let me know if you have any queries
 
Thanks
Ram
0
 

Author Comment

by:antcal
ID: 24094444
Thanks for the tip, I should have a chance to try and implement the suggestion later today.  I'll update you then.
0
 

Author Comment

by:antcal
ID: 24103092
I am still not 100% with this task.  Here is the sample code I have been playing with.  This code gives me 1,2,3, or 4 Text boxes.  It is close to what I need, however, I want unique sections.

I have included my working code snippet, and it has a desired output section below the working example.  I hope this is enough to help me wrap this up.
<html>
<head>
<script type="text/javascript">
     function showFields(num){
          container = document.getElementById('fields')
          container.innerHTML = ''
 
          for(i = 0; i < parseFloat(num); i ++){
               container.innerHTML += '<input type="text" /><br />'
               }
          }
</script>
</head>
 
<body>
<select onChange="showFields(this.options[this.selectedIndex].value)">
     <option value="0">Choose One:</option>
     <option value="1">Dispensed</option>
     <option value="2">Recieved</option>
     <option value="3">Return to Stock</option>
     <option value="4">REKO</option>
</select>
<br />
<div id="fields"></div>
<br><br><br>
<p><b>Desired Output for option DISPENSED, Recived (and other choices) would have a similar but diffrent output</b><br>
<input name="DispName" type="text" onFocus="value=''" value="Enter Name Here" size="30" maxlength="30"><br />
<input name="DispCenter" type="text" onFocus="value=''" value="Enter Center Here" size="30" maxlength="30"><br>
<input name="DispNumber" type="text" onFocus="value=''" value="Enter Number Here" size="30" maxlength="30"><br>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:antcal
ID: 31567303
Good direction for a skilled developer.  Due to my lack of skill in web development, I still had to find my own solution.  My solution used a java script to reveal a section of the web page using "tbody" tag.
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Website user account and password management 3 65
Help on HTML 1 83
Web Fraud scenarios to PoC F5  web fraud prevention 7 74
Forms that calculate points for wordpress 10 109
A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question