SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: JS Question

  1. #1
    SitePoint Wizard
    Join Date
    Apr 2000
    Posts
    1,483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey all,
    I'm sure this is easy to all you JS experts out there but I'm a newbie when it comes to JS
    Okay, I have a function:
    Code:
    function rate(rating)
    {
    	window.open('rate.php?id=<?php echo($siteid); ?>&rating=' + rating,'feedback','width=350,height=300')
    }
    And further down the page I have a combo box:

    Code:
    <select name=rating onClick="rate(this.value)">
    <option></option>
    <option value=1>10 - best</option>
    <option value=9>9</option>
    <option value=8>8</option>
    <option value=7>7</option>
    <option value=6>6</option>
    <option value=5>5</option>
    <option value=4>4</option>
    <option value=3>3</option>
    <option value=2>2</option>
    <option value=1>1 - worst</option>
    As you can probably tell, this script is to rate something. I want it so that when someone selects a value in the combo box, it opens a new window with my PHP file in it. But at the moment, it goes to the rating page even when the top option (blank at the moment) is selected - is there any way to stop that happening?

    Thanks in advance,

    James.



  2. #2
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey James,

    Just change your <select> line to:

    Code:
    <select name="rating" onchange="rate(document.forms[0].rating[document.forms[0].rating.selectedIndex].value)">
    Hope that helps,
    aDog


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
  •