Solved

combine three separate date select fields into one post value?

Posted on 2014-02-21
6
703 Views
Last Modified: 2014-02-21
Hi Experts,

In my form generated with server based classic ASP we have date select with three separate select fields.

date select
Would it be possible with client based scripts to transform this into a single form value without changing the looks and behavior in the form?

All help is welcome as long as it does not transforms the looks.

Thanks
0
Comment
Question by:Steynsk
6 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39876604
The answer: There's a very good chance you can do this client side with jquery. You would need to supply a typical view source of a rendered page that has the form on it.

I'm not an expert in classic asp, but you could also do things like this server side quite easily in asp.net.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39876635
<%
' in asp
' assuming vars for day, month, year

day=1
month=2
year=2014
theDate=day&"/"&month&"/"&year
response.write theDate

%>
<input type="hidden" name="fulldate" value="<%=theDate%>">

Open in new window

0
 
LVL 22

Expert Comment

by:Om Prakash
ID: 39876687
Assuming you have placed a button and on click of button you want to combine these fields, try the following code:


assuming dropdown names are d,m,y

<script language="Javascript">
function post()
{
	var d = document.getElementById("d");
    var dstr = d.options[d.selectedIndex].value;

  	var m = document.getElementById("m");
    var mstr = m.options[m.selectedIndex].value;

    var y = document.getElementById("y");
    var ystr = y.options[y.selectedIndex].value;

    alert(dstr + "/" + mstr + "/" + ystr);
    
    //submit the form

}
</script>
<input type=button name=b1 value="Go" onclick="post()"/>

Open in new window

0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 54

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39876737
Using the change event on the selects to populate a hidden text field
<!doctype html>
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
$(function() {
  $('select').change(function() {
    $('#dob').val($('#jaar').val() + '-' + $('#maand').val() + '-' +  $('#dag').val());
  });
});

</script>
<style type="text/css">
</style>
</head>
<body>
  <div class="dob-container">
    <input type="hidden" id="dob" name="dob" />
    <select id="dag" name="dag">
      <option value="">Dag</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    <select id="maand" name="maand">
      <option value="">Maand</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    <select id="jaar" name="jaar">
      <option value="">Jaar</option>
      <option value="2009">2009</option>
      <option value="2010">2010</option>
      <option value="2011">2011</option>
      <option value="2012">2012</option>
      <option value="2013">2013</option>
    </select>
  </div>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:Steynsk
ID: 39876981
Thanks julianH excellent.
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39877057
You are welcome - thanks for the points.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
div to fit another div 8 23
How to create a textarea which saves text in HTML 8 37
Button and js nou working 3 8
JS does not refresh 6 21
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

821 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