Solved

combine three separate date select fields into one post value?

Posted on 2014-02-21
6
745 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
[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
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 53

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 57

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 57

Expert Comment

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

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

738 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