SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Memphis, TN
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript auto radio link

    I'd like to be able to click a submit button and have javascript automatically check the value of the selected radio button for a URL, and then forward the browser there. Anyone know how to do this?

    Also, this functionality may actually be served within a document.write. Is it possible to include more javascript such as this described radio/submit, within the document.write?

    thanks for any pointers..

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post your HTML, please.

    Could you explain further:
    ...this functionality may actually be served within a document.write.
    ::: certified wild guess :::

  3. #3
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Memphis, TN
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't have any html...asking how this might be done.

    * radio option 1
    * radio option 2
    -- submit --

    when submit is clicked, the user is sent to a website based on the radio option's value without contacting a script first.


    The second part of the question is basically .. can more Javascript exist within a document.write?

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just set the form's action attribute to a default url, and use the radios like so:
    Code:
    <input type="radio" name="actionurl" value="some_url" onclick="this.form.action=this.value" />
    <input type="radio" name="actionurl" value="some_other_url" onclick="this.form.action=this.value" />
    JavaScript can be output using document.write/writeln - they're just alternative ways of outputting to the document stream. One warning - do this:
    Code:
    document.writeln('<\/script>');
    ...at the end of the script - or the currently running script (the one that's writing the 'new' script) will think it's done and go home!

    This sort of thing is rarely necessary. That's why I asked. Usually a simpler, neater way.
    ::: certified wild guess :::

  5. #5
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Memphis, TN
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks very much! I'm working on a project in which the user will be remotely syndicating something on their web site, so the first script is that call to my server. In order to include javascript within THAT code, I'm thinking the only way is to include it within the document.write which is used to display the remote include. There might be a better way, I don't know...


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
  •