Results 1 to 7 of 7

Thread: I want to pass a arguument to my javascript function

  1. #1
    Join Date
    Mar 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I want to pass a arguument to my javascript function

    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


    PHP Code:


    <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?

    PHP Code:

    <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
    Last edited by fshaw; 03-04-2009 at 01:55 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Your php variables have have to be surrounded, like this:[
    PHP Code:
    <?php echo $vbprase[]; ?>
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I have edited the orgonal posting with what you are saying is it correct now?

    Quote Originally Posted by Nile View Post
    Your php variables have have to be surrounded, like this:[
    PHP Code:
    <?php echo $vbprase[]; ?>
    Thanks - I have edited the orginal post with what you said i hope it is what you ment.


    PHP Code:

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

    THANKS

    Frank H. Shaw

  4. #4
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    im sorry but i don't understand what you are trying to do. why do you need php in the javascript
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  5. #5
    Join Date
    Mar 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I do not someone else told me that Nile I think that is what he ment I guess he wrong

    Quote Originally Posted by Master_script_maker View Post
    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 :

    PHP Code:

    <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


    PHP Code:

    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
    Last edited by fshaw; 03-04-2009 at 01:56 AM.

  6. #6
    Join Date
    Mar 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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?
    Last edited by fshaw; 03-02-2009 at 04:20 AM.

  7. #7
    Join Date
    Mar 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •