Solved

combine three separate date select fields into one post value?

Posted on 2014-02-21
6
670 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
Comment Utility
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
Comment Utility
<%
' 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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
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
Comment Utility
Thanks julianH excellent.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are welcome - thanks for the points.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now