Tall order: text hyperlink that sets var value + submits form

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

    Tall order: text hyperlink that sets var value + submits form


    Folks,

    I am working on a contact db using PHP and MySQL. My results so far outputs
    a slimed down version of records to the browser. I would like to implement
    a method whereby the user can click on a text link which will then show the
    full record. I don't want to have hyperlinks with values incorporated in
    the link (thus, I don't want to have http://www.example.com?abc=1234) - I
    prefer to use a POST method thus what I would like to do is have my output
    listed inside a form. Each record would have unique hidden form value using
    either a <INPUT TEXT> or <INPUT CHECKBOX>. Each record would have a
    hyperlink so that when the hyperlink is pressed, its respective unique
    record ID is noted, then the form submitted.

    I know something like this is possible - I can work out the PHP/MySQL part
    of it myself - But my javascript is still far too junior to accomplish
    something like this.

    Can someone help steer me in the right direction? If they know of a working
    example I'm sure I could read and re-write the script to fit in with my
    project...

    Breaking my problem down a bit... I know I can have an onClick event in my
    <A HREF> tag... But how can I have it set a value in a hidden box, and then
    post the form?

    All help, via the newsgroup would be much appreciated...

    thanks,
    randelld


  • David Dorward

    #2
    Re: Tall order: text hyperlink that sets var value + submits form

    Randell D. wrote:
    [color=blue]
    > I am working on a contact db using PHP and MySQL. My results so far
    > outputs a slimed down version of records to the browser. I would like to
    > implement a method whereby the user can click on a text link which will
    > then show the full record. I don't want to have hyperlinks with values
    > incorporated in the link (thus, I don't want to have
    > http://www.example.com?abc=1234) - I prefer to use a POST method[/color]

    Why? You aren't changing anything on the server, so this is what GET is
    designed for. Aside from being easier to deal with, it will allow people to
    bookmark specific entries.
    [color=blue]
    > thus what I would like to do is have my output
    > listed inside a form. Each record would have unique hidden form value
    > using either a <INPUT TEXT> or <INPUT CHECKBOX>.[/color]

    Why not using type="hidden"? That's designed for hidden inputs?
    [color=blue]
    > Each record would have a hyperlink so that when the hyperlink is pressed,
    > its respective unique record ID is noted, then the form submitted.[/color]

    Great. So you are depending on JavaScript. This is not a good idea. The most
    important thing to learn about JavaScript, is when not to use it.

    This domain name has been registered with Gandi.net. It is currently parked by the owner.

    [color=blue]
    > Breaking my problem down a bit... I know I can have an onClick event in my
    > <A HREF> tag... But how can I have it set a value in a hidden box, and
    > then post the form?[/color]

    It sounds like you would be better off having multiple forms, then trying to
    edit one form based on the user selection.

    --
    David Dorward http://dorward.me.uk/

    Comment

    • Randell D.

      #3
      Re: Tall order: text hyperlink that sets var value + submits form


      "David Dorward" <dorward@yahoo. com> wrote in message
      news:bnqch2$9a3 $1$830fa7b3@new s.demon.co.uk.. .[color=blue]
      > Randell D. wrote:
      >[color=green]
      > > I am working on a contact db using PHP and MySQL. My results so far
      > > outputs a slimed down version of records to the browser. I would like[/color][/color]
      to[color=blue][color=green]
      > > implement a method whereby the user can click on a text link which will
      > > then show the full record. I don't want to have hyperlinks with values
      > > incorporated in the link (thus, I don't want to have
      > > http://www.example.com?abc=1234) - I prefer to use a POST method[/color]
      >
      > Why? You aren't changing anything on the server, so this is what GET is
      > designed for. Aside from being easier to deal with, it will allow people[/color]
      to[color=blue]
      > bookmark specific entries.
      >[color=green]
      > > thus what I would like to do is have my output
      > > listed inside a form. Each record would have unique hidden form value
      > > using either a <INPUT TEXT> or <INPUT CHECKBOX>.[/color]
      >
      > Why not using type="hidden"? That's designed for hidden inputs?
      >[color=green]
      > > Each record would have a hyperlink so that when the hyperlink is[/color][/color]
      pressed,[color=blue][color=green]
      > > its respective unique record ID is noted, then the form submitted.[/color]
      >
      > Great. So you are depending on JavaScript. This is not a good idea. The[/color]
      most[color=blue]
      > important thing to learn about JavaScript, is when not to use it.
      >
      > http://tom.me.uk/scripting/submit.asp
      >[color=green]
      > > Breaking my problem down a bit... I know I can have an onClick event in[/color][/color]
      my[color=blue][color=green]
      > > <A HREF> tag... But how can I have it set a value in a hidden box, and
      > > then post the form?[/color]
      >
      > It sounds like you would be better off having multiple forms, then trying[/color]
      to[color=blue]
      > edit one form based on the user selection.
      >
      > --
      > David Dorward http://dorward.me.uk/[/color]


      First off... I did mean to refer to a HIDDEN tag - the words didn't come out
      the way I anticipated - my fault - sorry for being unclear...

      Anyway... Your proposed solution though: I had thought of something like
      that (though I have to admit, the CSS idea was new to me and a nice touch) -
      but the solution doesn't meet my problem entirely... I would prefer to have
      a numeric value passed (the record ID) as opposed to the the value of the
      submit button... Thus if I were to have something like a hidden field, a
      hyperlink around the persons name, address and other contact details which,
      when clicked, passed a record id (numeric value) to the hidden field, and
      then submitted the form... that is more preferable.

      I've read the link you supplied - It briefly details incorrect usages and
      summarises it with "all are very poor usage of the A element". In my
      ignorance, I would beg to differ (I'm not looking to get flamed but am open
      to being educated through this newsgroup).

      Why else do the A tag have the onClick feature? I know that the A tag is for
      navigational purposes, but the onClick feature allows one extra
      functionality.. .

      Most modern day graphical browsers have javascript - It helps reduce the
      load on the server and share some of the processing with the client. If
      users are to disable javascript, then they disable functionality and are
      unlikely to see something any more informative then the equivalent of junk
      mail that would come through the door (ie fixed/static and less
      interactive). Putting it bluntly, one doesn't get something for nothing in
      this world - Even if its just free (as in beer) - folk always get something,
      be it a laugh or a smile (ie happiness), information, goods or cash for the
      bank...

      Roughly speaking one could compare javascript to whistles and bells, music
      and lights in a bricks and mortar business. If given the choice of two
      stores selling the same goods on the same street, I'd be more likely to
      enter the brighter, colourful and more welcoming one then the grey bricked
      1950s paint job dimly lit uuncomfortably cold looking building...

      While I do intend to design my pages to have a static (non javascript)
      navigation on them, I aim to place less than 10% of my resources in this way
      as if they (the client/viewers) are not interested in helping me help them
      then they can spend extra time navigating elsewhere to find their info... I
      know its crude - but I aim to create an application online (small time
      application service provider) and I have 18months experience identifying my
      market... During this time I analysed log files and discovered less than 2%
      (of my likely market) had javascript disabled - some months went by where
      less than one tenth of 1% were non-javascript browsers.

      So... again... I do like your CSS solution - kudos for that and its
      something I'm sure I will refer to later - but for now, I'd prefer to have a
      clickable hyperlink that writes a numeric value in to a hidden field and
      then submits the form...

      Can you help me there?

      Cheers
      Randell D.


      Comment

      • Randell D.

        #4
        Re: Tall order: text hyperlink that sets var value + submits form


        "Randell D." <you.can.email. me.at.randelld@ yahoo.com> wrote in message
        news:CC0ob.2192 66$9l5.170568@p d7tw2no...[color=blue]
        >
        > Folks,
        >
        > I am working on a contact db using PHP and MySQL. My results so far[/color]
        outputs[color=blue]
        > a slimed down version of records to the browser. I would like to[/color]
        implement[color=blue]
        > a method whereby the user can click on a text link which will then show[/color]
        the[color=blue]
        > full record. I don't want to have hyperlinks with values incorporated in
        > the link (thus, I don't want to have http://www.example.com?abc=1234) - I
        > prefer to use a POST method thus what I would like to do is have my output
        > listed inside a form. Each record would have unique hidden form value[/color]
        using[color=blue]
        > either a <INPUT TEXT> or <INPUT CHECKBOX>. Each record would have a
        > hyperlink so that when the hyperlink is pressed, its respective unique
        > record ID is noted, then the form submitted.
        >
        > I know something like this is possible - I can work out the PHP/MySQL part
        > of it myself - But my javascript is still far too junior to accomplish
        > something like this.
        >
        > Can someone help steer me in the right direction? If they know of a[/color]
        working[color=blue]
        > example I'm sure I could read and re-write the script to fit in with my
        > project...
        >
        > Breaking my problem down a bit... I know I can have an onClick event in my
        > <A HREF> tag... But how can I have it set a value in a hidden box, and[/color]
        then[color=blue]
        > post the form?
        >
        > All help, via the newsgroup would be much appreciated...
        >
        > thanks,
        > randelld
        >
        >[/color]

        I think I got what I was looking for... my lack of javascript experience had
        made my previous attempts to fail because I had neglected to use 'value' (an
        object? class? whatever its called) in my original script... but for anyone
        that is interested in playing around themselves... this is my rough test
        script that I plan on implementing with my PHP/MySQL scripts... Thank to all
        who offered help via posts and emails (newsposts are always preferable).

        <script language="JavaS cript" type="text/JavaScript">
        function one(myvalue)
        { document.form1. myname.value=my value;
        return(TRUE);
        }
        </script>

        <form name="form1" action="" method="post">N ame:
        <input name="myname" type="text" value="">
        <a href="#" onClick="one(3) ; return">Click Here</a>
        </form>


        Comment

        • David Dorward

          #5
          Re: Tall order: text hyperlink that sets var value + submits form

          Randell D. wrote:
          [color=blue]
          > I've read the link you supplied - It briefly details incorrect usages and
          > summarises it with "all are very poor usage of the A element". In my
          > ignorance, I would beg to differ (I'm not looking to get flamed but am
          > open to being educated through this newsgroup).
          >
          > Why else do the A tag have the onClick feature?[/color]

          Because all rendered elements have an onclick event! And because you can do
          USEFUL things with it that don't cause a page to depend on JavaScript.

          For instance:

          <h3 id="sheep">A subheading: Sheep</h3>

          and somewhere else on the page:

          .... however, <a href="#sheep"
          onclick="docume nt.getElementBy Id('sheep').sty le.backgroundCo lor='yellow';"> sheep</a>
          are a special case.

          (A nicer version can be seen at <http://dorward.me.uk/software/frag/>)
          [color=blue]
          > I know that the A tag is for navigational purposes, but the onClick
          > feature allows one extra functionality.. .[/color]

          Yes - EXTRA.
          [color=blue]
          > Most modern day graphical browsers have javascript[/color]

          And a lot of people disabled it
          [color=blue]
          > - It helps reduce the load on the server and share some of the processing
          > with the client.[/color]

          Using JavaScript to submit a form instead of a submit button does not reduce
          the load on the server.
          [color=blue]
          > If
          > users are to disable javascript, then they disable functionality and are
          > unlikely to see something any more informative then the equivalent of junk
          > mail that would come through the door (ie fixed/static and less
          > interactive).[/color]

          The great thing about the web is that its very easy to design a page that it
          static and less interactive for users who don't have JavaScript, but has
          flashy effects for those who do.
          [color=blue]
          > Roughly speaking one could compare javascript to whistles and bells, music
          > and lights in a bricks and mortar business. If given the choice of two
          > stores selling the same goods on the same street, I'd be more likely to
          > enter the brighter, colourful and more welcoming one then the grey bricked
          > 1950s paint job dimly lit uncomfortably cold looking building...[/color]

          See my previous paragraph in this post.
          [color=blue]
          > While I do intend to design my pages to have a static (non javascript)
          > navigation on them, I aim to place less than 10% of my resources in this
          > way as if they (the client/viewers) are not interested in helping me help
          > them then they can spend extra time navigating elsewhere to find their
          > info...[/color]

          Not all users have don't run JavaScript do so by choice, and there is
          nothing stopping you from writing static HTML... which looks nicer if the
          user has CSS... and gets flashy if they have JavaScript. Good JavaScript is
          a great deal about manipulating a page rather then adding to it.


          --
          David Dorward http://dorward.me.uk/

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: Tall order: text hyperlink that sets var value + submits form

            David Dorward wrote:
            [color=blue]
            > Randell D. wrote:[color=green]
            >> I've read the link you supplied - It briefly details incorrect usages and
            >> summarises it with "all are very poor usage of the A element". In my
            >> ignorance, I would beg to differ (I'm not looking to get flamed but am
            >> open to being educated through this newsgroup).
            >>
            >> Why else do the A tag have the onClick feature?[/color]
            >
            > Because all rendered elements have an onclick event![/color]

            You have a strange idea of "rendered elements." According to the HTML 4.01
            Specification, the `onclick' attribute is valid for "All elements but
            APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME,
            ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE."[1] I cannot find a definition
            of "rendered elements" in the Specification, however I do consider APPLET,
            BR, FONT, FRAME and IFRAME to be rendered elements as a rendering engine
            (like Netscape Gecko) is required to display them.

            But no matter that intrinsic event handlers are part of HTML 4.01, their
            support depends on the DOM of the UA.[2] `img' elements in the NS4-DOM,
            e.g., have no `onclick' event handler (at least none that is working), so
            the `a' element and its `onclick' handler is required there if you want
            to execute JavaScript code when clicking an image.


            PointedEars
            ___________
            [1] http://www.w3.org/TR/html4/index/attributes.html
            [2] http://www.w3.org/TR/html4/interact/....html#h-18.2.3

            Comment

            • Jim Ley

              #7
              Re: Tall order: text hyperlink that sets var value + submits form

              On Thu, 06 Nov 2003 12:24:22 +0100, Thomas 'PointedEars' Lahn
              <PointedEars@we b.de> wrote:
              [color=blue]
              >David Dorward wrote:[/color]
              [color=blue]
              > however I do consider APPLET,
              >BR, FONT, FRAME and IFRAME to be rendered elements as a rendering engine
              >(like Netscape Gecko) is required to display them.[/color]

              APPLET, FRAME, IFRAME are containers for other content - they are not
              rendered, the content is. BR is not rendered (it takes no space -
              what would you click on?) FONT is the exception certainly.
              [color=blue]
              > so
              >the `a' element and its `onclick' handler is required there if you want
              >to execute JavaScript code when clicking an image.[/color]

              In NN4, which is not an HTML 4.01 user agent.

              Jim.
              --
              comp.lang.javas cript FAQ - http://jibbering.com/faq/

              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: Tall order: text hyperlink that sets var value + submits form

                Jim Ley wrote:
                [color=blue]
                > [...] Thomas 'PointedEars' Lahn [...] wrote:[color=green]
                >> David Dorward wrote:[/color]
                >[color=green]
                >> however I do consider APPLET, BR, FONT, FRAME and IFRAME to be rendered
                >> elements as a rendering engine (like Netscape Gecko) is required to
                >> display them.[/color]
                >
                > APPLET, FRAME, IFRAME are containers for other content - they are not
                > rendered,[/color]

                IBTD, what do you think Gecko does when I specify

                <iframe
                src="foobar.htm l"
                width="200" height="100"
                style="width:50 %; border:2px solid red"[color=blue]
                >[/color]
                <a href="foobar.ht ml">blurb</a>
                </iframe>

                ?
                [color=blue]
                > the content is. BR is not rendered[/color]

                Depends on what you call `(to) render'. It is an interpreted element
                that results in different display, namely a hard line-break.
                [color=blue][color=green]
                >> so the `a' element and its `onclick' handler is required there if you
                >> want to execute JavaScript code when clicking an image.[/color]
                >
                > In NN4, which is not an HTML 4.01 user agent.[/color]

                Which (if true) is irrelevant here since it was only an example for the fact
                that recommended event( handler)s need not to be part of the DOM of the UA.
                OTOH, there are proprietary event( handler)s supported only by specific
                UAs, like IE's `onmousewheel'.


                PointedEars

                Comment

                Working...