Click to See Complete Forum and Search --> : Functionally and otherwise challenged


PuzzledAlways
04-07-2003, 07:55 AM
I was left an old form with various validations to update. The end-user now wants the person using the form to select a time,(three elements to the time: hours, minutes and am or pm) from select lists. Fine, I did that. But in writing the data out to a file I can only use one field, combining the results of the 3 selections.

I think I know what I need but all my attempts have failed.

I think I need a function to capture the data from the selections, concatenate them into a hidden field and write that out to the file when the form is submitted.


My function for validation on making a selection is decent.

function notSelected(inSelect)
{
var i = inSelect.selectedIndex;
if (i == 0)
{
return true;
}else{
return false;
}
}

My other function sucks big time. Here is an example of my jibberish

function Time(testStr)
{
var FSTARTTIME = (in_data.SHOUR.value + in_data.SMINUTE.value + in_data.SAMPM.value);
return;
}

Then later I want to write out the stuff in FSTARTTIME.
But of course FSTARTIME never has any thing in it.

Whew, I confess, I am clueless.

Thanks for any assistance

khalidali63
04-07-2003, 08:27 AM
Well here is one way to do this.
in your hours minutes and seconds list boxes onchange events add the following line of code

onchange="document.formName.hiddenFieldName.value = this.options[this.selectedIndex].value"

and then create a hidden field in the form

<input type="hidden" name="hh" value="">

<input type="hidden" name="mm" value="">

<input type="hidden" name="ss" value="">

now what happend anytime a selection is made it will be updated to the hidden field and upon submittion will go to your form processing.

There are multiple variations you can try.

Cheers

Khalid

PuzzledAlways
04-07-2003, 08:53 AM
Thanks for the fast reply.

Could you explain or tell me if I understand that first line of code.

onchange="document.formName.hiddenFieldName.value = this.options[this.selectedIndex].value"


My interpretation, when they make a selection, the value of the hidden field will be equal to the value of the selected item.
Is the selectedIndex =length of string ?
Is the this.options= pointer ?
Will it be appending to the hidden field ?

Will that concatenate the three items into one field ?

I better get some more coffee.