PDA

View Full Version : My form does not seem to call me javascript WHY



fshaw
03-01-2009, 10:51 PM
My strength is not java script and with the complex issues of dealing with the Vbulletin interface and then the java script which i do not really understand yet fully I hopeing some good soul will come to my add fast and get me through this.

I do not expect that I will find someone that has the knowelage of vbulletin but I need to be correct java script first but if someone knows Vbulletin i modifyed the calendar_jump which is calendarjump in the templete system.

Here goes the problem is my form is not calling up my java script - even allought the java is not doing anything right now I have dump some idea of what i want to do inside it for clearlty to my idea what i am trying to do!

The point is I need my java script function "process_selected(this.form)" to be called before the submitting of the form in the form of a $_GET to the server.








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

alert('This is working!');

form.submit();

}

</script>

<form name="myform" 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 the posting above and tell me what i am doing wrong to have the handshaking between my form and the java script WHY IS IT NOT BEING CALLED.

THANKS

Frank H. Shaw

Master_script_maker
03-01-2009, 11:22 PM
<script type="text/javascript"> function process_selected(this.form) {

on.form.submit();

}

</script>
try changing both highlighted to a single variable, for instance form:
<script type="text/javascript"> function process_selected(form) {

form.submit();

}

</script>

fshaw
03-01-2009, 11:35 PM
the here is the two places i changed




<form name="myform" action="calendar.php" method="get">





and




input type="submit" class="button" value="$vbphrase[go]" onclick="process_selected(this.form)" > <br />



But please explain how the javascript function works

I am going to call a php function from within my javascript function once i get the handshaking to happen.

THANKS

Frank H. Shaw

Master_script_maker
03-01-2009, 11:44 PM
you have to add the code to the form: <form name="myform" action="calendar.php" method="get" onsubmit="process_selected(this)">. So when the form is submitted (onsubmit) , the function process_selected will be run and it will pass a pointer to the form (this) as a variable.
The function will accept a variable and assign it the name form, and then it will submit it (form.submit()).

fshaw
03-02-2009, 12:01 AM
you have to add the code to the form: <form name="myform" action="calendar.php" method="get" onsubmit="process_selected(this)">. So when the form is submitted (onsubmit) , the function process_selected will be run and it will pass a pointer to the form (this) as a variable.
The function will accept a variable and assign it the name form, and then it will submit it (form.submit()).


Please review my orginal post and see if i have it correct now?

Does the line below stay or change?




<input type="submit" class="button" value="$vbphrase[go]" onclick="process_selected(this.form)" > <br />



THANKS

Frank H. Shaw

Master_script_maker
03-02-2009, 12:25 AM
you would change
<input type="submit" class="button" value="$vbphrase[go]" onclick="process_selected(this.form)" > <br /> to
<input type="submit" class="button" value="$vbphrase[go]"> <br />

fshaw
03-02-2009, 12:40 AM
My alert is now working so the handshaking is happening now half way home now THANKS.

As before i changed the above orginal post to reflex the changes in my posting.

Here is what I want to do is I want my java script to call a function outside the templete but located in some php file in the same domain on the server so let me explain that later!

But first I need to know can I pass the value of my hidden input field to my javascript function please give me a example THANKS?

Here is what i mean?




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




I want my java function have access to my "me" is there a way to do that?

THANKS

Frank H. Shaw

Master_script_maker
03-02-2009, 01:04 AM
in the function you would use: form[name] so form["me"], and if you want to access its value: form["me"].value

fshaw
03-02-2009, 01:16 AM
in the function you would use: form[name] so form["me"], and if you want to access its value: form["me"].value

I need a better explaination on what you are trying to tell me a example would help - I am sorry this is kind new to me the javascript stuff so I am a little slow!

Do I make the change in my form or in my javascript or both?

THANKS

Frank H. Shaw

fshaw
03-02-2009, 01:32 AM
Do you mean this?




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

alert('This is working!');

$me = 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>





If the javascript is correct what has to change in the form its self if anything?

THANKS

Frank H. Shaw

Master_script_maker
03-02-2009, 03:04 AM
try:
<script type="text/javascript"> function process_selected(form) {

alert('This is working!');

$me = 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> you could leave the function variable as it was, and that should should be it :)

fshaw
03-02-2009, 03:11 AM
THANKS

For all you help on this matter - I have another thread going that will contine from this point.