Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 827
  • Last Modified:

combine three separate date select fields into one post value?

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
Steynsk
Asked:
Steynsk
1 Solution
 
Tom BeckCommented:
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
 
Scott Fell, EE MVEDeveloperCommented:
<%
' 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
 
Om PrakashCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Julian HansenCommented:
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
 
SteynskAuthor Commented:
Thanks julianH excellent.
0
 
Julian HansenCommented:
You are welcome - thanks for the points.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now