Posting a variable Onclick

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Posting a variable Onclick

    Hi

    I want to have a text link on my page - say for instance 'javascript' where
    clicking on this link would submit a form and also pass a variable name
    such as META_Name="java script" with the form - is there a simple function
    to do this ?

    Many thanks for any advice


    John
  • John

    #2
    Re: Posting a variable Onclick

    John <john209093@hot mail.com> wrote in
    news:Xns949B60F C8E862atari2010 NOSPAMhotma@195 .114.230.35:
    [color=blue]
    > john209093@hotm ail.com[/color]

    Following on from this I've now got this far :


    <script>
    function searchcategory( category) {
    addfield (form1, 'hidden', 'META_Name', category);
    document.form1. submit();
    }
    </script>

    <form name="form1" method="post" action ="">
    <a href="bla" OnClick="search category('strin g')">String</A>
    </form>

    When clicking on string however, I get an Object Expected error on the
    addfield line.

    Can anyone see the problem or perhaps suggest an easier way ?

    Thanks

    John

    Comment

    • Ivo

      #3
      Re: Posting a variable Onclick

      "John" <john209093@hot mail.com> wrote[color=blue]
      > <script>
      > function searchcategory( category) {
      > addfield (form1, 'hidden', 'META_Name', category);
      > document.form1. submit();
      > }
      > </script>
      >
      > <form name="form1" method="post" action ="">
      > <a href="bla" OnClick="search category('strin g')">String</A>
      > </form>
      >
      > When clicking on string however, I get an Object Expected error on the
      > addfield line.[/color]

      I may be missing things, but I am not familiar with a native "addfield"
      function. Perhaps you need to write something like this first:
      function addfield(formna me,fieldname,fi eldtype,fieldva lue){
      var x=document.crea teElement('inpu t');
      x.type=fieldtyp e;
      x.value=fieldva lue;
      document.forms[formname].appendChild(x) ;
      }
      and put quotes around form1 to make it read addfield( "form1", etc.)
      HTH
      Ivo


      Comment

      • Rich

        #4
        Re: Posting a variable Onclick

        Thanks Ivo, this works great :)

        "Ivo" <no@thank.you > wrote in news:403e75c9$0 $63133$a344fe98
        @news.wanadoo.n l:
        [color=blue]
        > "John" <john209093@hot mail.com> wrote[color=green]
        >> <script>
        >> function searchcategory( category) {
        >> addfield (form1, 'hidden', 'META_Name', category);
        >> document.form1. submit();
        >> }
        >> </script>
        >>
        >> <form name="form1" method="post" action ="">
        >> <a href="bla" OnClick="search category('strin g')">String</A>
        >> </form>
        >>
        >> When clicking on string however, I get an Object Expected error on the
        >> addfield line.[/color]
        >
        > I may be missing things, but I am not familiar with a native "addfield"
        > function. Perhaps you need to write something like this first:
        > function addfield(formna me,fieldname,fi eldtype,fieldva lue){
        > var x=document.crea teElement('inpu t');
        > x.type=fieldtyp e;
        > x.value=fieldva lue;
        > document.forms[formname].appendChild(x) ;
        > }
        > and put quotes around form1 to make it read addfield( "form1", etc.)
        > HTH
        > Ivo
        >
        >
        >[/color]

        Comment

        Working...