Simple Question

Soldato
Joined
24 Nov 2002
Posts
16,378
Location
38.744281°N 104.846806°W
When parsing an url, such as:

url.php?name=John

How can replace the John with the contents of a select box, i.e. document.goit.select.value, so I'd have url.php?name=document.goit.select.value but working!

I'm sure this is just a simple syntax thing...

Help!
 
depends on the context you are using it... if on submission:
Code:
<script language="JavaScript">
function MySubmit ()
{
    window.location = "http://www.yoursite.com/page.html?var=" + document.getElementbyID(goit).value;
    return false;
}
</script>
<form action="" method="post">
    <select id="goit">
        <option>blah</option>
    </select>
    <input type="button" value="Submit" onClick="MySubmit()" />
</form>
 
That's still fine, just remove the button and move the onclick to the anchor:
Code:
<a href="#" onclick="MySubmit()">Click me!!</a>

Though I'm not sure if that javascript will work, but I'll test out and post back.
 
Back
Top Bottom