SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    java script:document.FORMNAME.submit();

    hi, i want to use a link instead of a submit button to go to the next page...

    pls go to this page:
    http://www.certifyexpress.com/exam/bea/2.php

    i want to go to the next page by just clicking the questions. i will delete off the radion button and the submit button.

    the problem i'm facing is, i can't pass thevalue of the select box (Number of questions). if i choose 20, it will only show me to 10 questions.

    how can i solve that problem?? someone suggest me to use java script:document.FORMNAME.submit();

    how am i going to use that?

    my form is like this:


    PHP Code:
    print "<form action=\"$script\" method=\"post\">\n"
    and my link (to be clicked to go to another page):

    PHP Code:
    print "<td bgcolor=$table_color_2 width=90%><font face=\"$font_face\" color=\"$font_color\" size=2><a href=\"script?quiz=$quiz_id\"><b>$quiz_name</b><br><font size=1>$quiz_desc</font></font></a></td>"
    pls advice...

  2. #2
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it is pretty easy
    Be carefull javascript is case sensitive
    <A href="javascript:document.nameofform.submit()">Submit</A>

  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 joyce,

    Let me get this straight. You want to eliminate both the radio button and the submit button, leaving only the selection list. And upon changing the selection or pressing a link, going to a new page or submitting a form? Which?

    If the selection list is the only element in the form, you can go to a new page with:

    <form....>
    <select ...onchange="this.location = this.options[this.selectedIndex].value">
    <option value='somepage.php?10'>10</option>
    <option value='somepage.php?20'>20</option>
    <option value='somepage.php?30'>30</option>
    </select>
    </form>

    if you want to use a link instead of the onChange:

    1) do not insert the onChange
    2) <a href ="#" onClick="doIt(this.form)"....
    3) within the function doIt(formObj), loop through the selection list, find the selected option, then this.location= it

    If there are more than one element in the form and you need its value, you would add them to url as I did the option's value. You can use location.search.substr(1) to parse the value from the location.href on the new page.

    Does this mean you will certify me?

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


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
  •