PDA

View Full Version : I want to pass a arguument to my javascript function



fshaw
03-02-2009, 02:56 AM
Not just any value but the value in my forms hidden input value what i am doing wrong here is the javascript function and my form is below

Here is the problem now






<script type="text/javascript"> function process_selected(form) {

alert('This is working!');

var myme = form["me"].value;

form.submit();
}
</script>


<form name="myfrom" action="calendar.php" method="get" onsubmit="process_selected(this)" >
<div class="smallfont" style="text-align:$stylevar[left]; white-space:nowrap">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="month" value="$month" />
<input type="hidden" name="year" value="$year" />
<input type="hidden" name="do" value="$docalendar" />
<strong>$vbphrase[Lodge_Calendar]</strong><br />
<select name="c" >
<optgroup label="$vbphrase[please_select_one]">
$jumpcalendarbitsl
</optgroup>
<input type="hidden" name="me" value='2'" />
</select>
<input type="submit" class="button" value="$vbphrase[go]" > <br />
</div>
</form>



Please review what is posted above and tell me what i am doing wrong?




<input type="hidden" name="me" value='2'" />



The above is the hidden value I am trying to pass to through to my javascript function.

THANKS

Frank H. Shaw

Nile
03-02-2009, 02:58 AM
Your php variables have have to be surrounded, like this:[


<?php echo $vbprase[]; ?>

fshaw
03-02-2009, 03:06 AM
Your php variables have have to be surrounded, like this:[


<?php echo $vbprase[]; ?>


Thanks - I have edited the orginal post with what you said i hope it is what you ment.





<?php $me = form["me"].value; ?>




THANKS

Frank H. Shaw

Master_script_maker
03-02-2009, 03:14 AM
im sorry but i don't understand what you are trying to do. why do you need php in the javascript

fshaw
03-02-2009, 03:44 AM
im sorry but i don't understand what you are trying to do. why do you need php in the javascript

I will remove the php - I edited my orginal post - All I want to do is assign a value form["me"].value to a varable to be able to pass this varable out to another function like this :




<script type="text/javascript"> function process_selected(form) {

alert('This is working!');

var myme = form["me"].value;

var retval = trap_calandar_jump(myme);


form.submit();
}

</script>




Now my function that resides outside the java would be this





trap_calandar_jump($jump)

{

switch ($jump) {

case 1:

// Logic here Jump drop down 1

break;

case 2:

// Logic here Jump drop down 2 the $me value = '2'

break;

case 3:

// Logic here Jump drop down 3

break;

}//switch

return $something;

}




So as you see there is a lot more to this then just the origail posting. I have taken out the actual logic but I need to do some house keeping before the submitting of the actual form but it is cridical that my function returns to the javascript before submiting the form.

THANKS

Frank H. Shaw

fshaw
03-02-2009, 03:57 AM
Now after explining what i am trying to do I hope it is posiable to do - the question what i just out lined above i think would work logicly should is it posiable to do or can I not call a server side function in with out useing ajax?

I am trying to keep things as simple as posiable what i plan to do in my housekeeping and for one things is to load the values selected in to a control array so that once the form is submited the control array will have what was selected and durn the reloading of the page it can be checked.

Also I want to posiable maintain a log of the selected calandar from the dropdown the sky is the limit as to what I want to do before the submiting of the form.

So can I call my php function located in a php file on the server with my javascript function is this allowed.

Now the file is in a include so that it actaul is in the calendar.php so it is not really call a different file.

I hope what i am asking makes sence now?

fshaw
03-02-2009, 12:38 PM
I will be now creating a new thread in the ajax area of this web sites forums if there is one.

I have never used ajax but I do understand the general idea of it.

THANKS for all your help on getting my form to call my javascript and that part is now working great.

THANKS

Frank H. Shaw