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>
 
I wanted to call it has a href, as i have:

Code:
<a target="_self" href="../file.php?file1=BIT;" onclick="return confirm('Are you sure you wish to delete the file?');"

Not sure how to sort this out now...
 
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.
 
Dj_Jestar said:
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.
If I do that./.. I'lll loose my confirmation... how do I add that in the mysubmit()?
 
adjust the function to use the confirmation, or:
Code:
<a href="#" onclick="if((confirm('Are you sure?')) == true) { MySubmit(); }">Click Me!!</a>
 
Last edited:
Back
Top Bottom