需要Page 1 webform将变量传递到位于第2页的iframe的src部分

Noob looking for some help. I am a slow learner.

I have a small form on my front page which asks "arrival date" and "departure date." I need to capture the results of those two questions and pass it into the src portion of an iframe located on the page which appears when "submit" is pressed.

The src is NOT on the same server. It looks something like: www.bob.com/res.php3?day_a=VAR1&month_a=VAR2&day_d=VAR3&month_d=VAR4&

If you can help me I would appreciate all that you can offer, I am starting from scratch here.

The code on page 1 is borrowed and looks something like this:

    <script language="javascript">
function changeIFrame() {
   window.open('http://www.bob.com/res3.php');
   }
/***********************************************
* Drop Down Date select script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
***********************************************/

var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=document.getElementById(dayfield)
var monthfield=document.getElementById(monthfield)
var yearfield=document.getElementById(yearfield)
for (var i=0; i<31; i++)
dayfield.options[i]=new Option(i, i+1)
dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
for (var m=0; m<12; m++)
monthfield.options[m]=new Option(monthtext[m], monthtext[m])
monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
var thisyear=today.getFullYear()
for (var y=0; y<20; y++){
yearfield.options[y]=new Option(thisyear, thisyear)
thisyear+=1
}
yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}
</script>

<form action="" name="someform">
<select id="day_a">
</select> 
<select id="month_a">
</select> 
<select id="year_a">
</select> 
<input type="button" onclick="changeIFrame();" />
</form>

<script type="text/javascript">

//populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
window.onload=function(){
populatedropdown("day_a", "month_a", "year_a")
}
</script>

I tried using bob-the-destroyer's code in page 2 to grab these values but had no luck.

You can change the src attribute of the iframe is like this:

<script language="javascript">
function changeIFrame() {
   var day_a = document.getElementById("day_a").value;
   var month_a = document.getElementById("month_a").value;
   var newSrc = "www.bob.com/res.php?day_a=" + day_a + "&month_a=" + month_a;
   document.getElementById("my_iframe").src = newSrc;
}
</script>

<input id="day_a" type="text" />
<input id="month_a" type="text" />
<input type="button" onclick="changeIFrame();" />

<iframe id="my_iframe" src=""></iframe>

Taking from your comment from Spidy's answer, "the iframe is located on a second page, which is meant to load when the button is clicked.", it's conceptually just like the javascript way, except working with posted values made available to the server and a first-time page build...

<?php

// get UNIX TIMESTAMPS of client's posted form fields
$arrivalDate = strtotime(trim($_POST['arrivalDate']));
$departureDate = strtotime(trim($_POST['departureDate']));
if (!$arrivalDate OR !$departureDate)
    // you will need better validation and error handling than this though
    die("These aren't valid dates."); 

// parse month/day numeric values
$day_a = date('n', $arrivalDate);
$month_a = date('j', $arrivalDate);
$day_d = date('n', $departureDate);
$month_d = date('j', $departureDate);

// here echo HTML or escape out of PHP to begin building your page


// draw iframe using parsed values
echo "<iframe src=\"www.bob.com/res.php3?day_a=" . $day_a . "&month_a=" 
    . $month_a . "&day_d=" . $day_d . "&month_d=" . $month_d . "\"></iframe>";


// here echo more HTML or escape out of PHP to finish building your page

?>

Note on that last echo: it's sloppy and you could better disregard all that concatenation , but I segmented it just to better show where PHP variables should be placed.