SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Text Display

  1. #1
    SitePoint Zealot Drew630's Avatar
    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text Display

    Ok, I am trying to find a way to control text and store it in a variable. I want to have the follwing happen:
    Code:
    <input type = radio, name = test value = 1> text
    <input type = radio, name = test value = 2> text again
    ...
    ...
    ...
    <input type = radio, name = result value = 1> ???
    What I want for the ??? is the value of the first set of radio buttons. So if button test, value 1 was checked, then the ??? are replaced by a 1.

    I can do this with select boxes, but that looks ugly and would much rather do this with just the text, for a bett effect. I know that I need JAvascript to manipulate and I can do that, in fact I alreayd have it, the one sticking point is controlling what the ??? will be without physically typing it in. Any ideas?

    have I confused anyone?

    Drew
    ~Drew

    There Is No Greater Joy Than Soaring High On The Wings Of Your Dreams, Except Maybe The Joy Of Watching A Dreamer Who Has Nowhere To Land But In The Ocean Of Reality.

  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do it with a server-side rogramming language like PHP or ASP or een Perl....depending on if you're comfortable with it. I recommend against javascript for browser compattibility reasons. Sometimes you can't avoid it, but when I can I like to try.

    Incidentally, it's not necessary to double and triple post messages across the forums.

    Good luck.
    Sketch
    Aaron Brazell
    Technosailor



  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Drew,

    Is this still the march madness thingy? As I said before, it would involve creating a mess of div/layers and then rewriting the div/layer with the preceding 'pick'. Yes, it can be done, but not easily and probably not visually pretty (which if I remember right was your complaint about the selection lists).

    Sketch's statement brings me to another point: if you intend to save the results somewhere (other than a cookie -- which would involve even more coding) and then redisplay them, you would need a server-side solution.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  4. #4
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mhh maybe something like
    document.window.result.innerText = something
    i think this only works for explorer

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Clientside Serverside .. huh?

    I find that my low rating is rubbing off and people starting to understand me more

    well here goes.

    if you have information to store and return, and you're not leaving your environment, well why not USE the url?!

    Say you want to store a username, id, and a picture_choice..

    well use the damn url (server side programs use it, why shouldn't client side? eh?)

    var de=docuemnt.getElementById;
    top.self.location += '?username='+ de('user').value
    + '&id=' + de('id').value
    + '&picture=' + de('picture').value;
    ALTERNATIVELY:

    var fields=new Array('username','id','picture');
    for (i=0;i<fields.length;i++){
    top.self.location +=
    ((i==0)?'?':'&') +
    fields[i]+'='+de(fields[i]).value;
    }

    This last logic bundle (the i==0 one) isn't tested and may not work, but if not just use place and replace methods.

    This gives you TWO ways of passing your stored information to your CURRENT location... you can use the same method to pass it to hrefs etc. You can either do this by looping or by a handler:

    var hrefs=document.getElementsByTagName('A');
    for (i=0;i<hrefs.length;i++){
    for (i=0;i<fields.length;i++){
    de(hrefs[i]).href+=
    ((i==0)?'?':'&') +
    fields[i]+'='+de(fields[i]).value;
    }
    }

    OR
    Use an event handler to track and replace an href from a mouseclick before it happens.

    You now know how to make sure your variables are sent to the server... The page you GET will have these variables in it's url, so you don't need to use Server side languages to handle them.

    In the called window you just need to retrieve and set them:

    window.onload=sVariables
    var de=document.getElementById;

    function sVariables(){
    var h = top.self.window.location.href;
    var p = h.split(/?/);
    if (p[1]){
    var l = p[1].split(/&/);
    for (i=0;i<l.length;i++){
    var nv = l[i].split(/=/);
    if (de(nv[0]) de(nv[0]).value=nv[1];
    }
    }
    }

    This would handle your incoming variables and put them in input fields.

    I hope what i've said makes sense to you.

    Does anyone know how to make my DAMN indents work properly??? he he

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •