Closed Thread Icon

Preserved Topic: submitting form (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8388" title="Pages that link to Preserved Topic: submitting form (Page 1 of 1)" rel="nofollow" >Preserved Topic: submitting form <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 11-13-2002 08:22

I have a form, that when submitted (either 'enter' or clicking on 'submit') goes to a page who's URL is assembled via javascript. Such as...

<form method="post" action="" name="blah" onsubmit="location='/stats/' + blah.zip.value + '/';">
<input name="zip" type="text" />
<input type="button" value="Submit" />
</form>

There is a problem with this method. It is that while the destination page is correct, it doesn't change the URL in the IE address bar (which is quite strange). Is this the best method for pulling this off? I *REALLY* need to assemble the URL like this, and can't really set hidden values.

Ideas?

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 11-13-2002 08:50

//---------------------------------------------------------------------------------
function makeFormGo(pObjForm) {
window.location = '/stats/' + pObjForm.zip.value + '/';
}

action="javascript:makeFormGo(this);" //pass ~this~ pointer to omit "name" attribute


//I think you can write it inline like this... but I didn't check, sorry.----------

action="javascript:window.location = '/stats/' + this.zip.value + '/';"

//---------------------------------------------------------------------------------


???

That's the best I can do. It's late.

[edit]Why. Why am I, "Neurotic" anyhow. Was this just a ramdom selection?[/edit]

[This message has been edited by Rooster (edited 11-13-2002).]

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 11-13-2002 10:17

there are varying levels of sanity in this asylum.... and no, being a Rooster does not save you from this grading scheme.

Nevel
Bipolar (III) Inmate

From: Amsterdam
Insane since: Jun 2002

posted posted 11-13-2002 16:00

Hmz, that reminds me of the good old times when I used to generate HTML-forms.

Like already posted, javascript can change your url properly. What you're doing right now, is changing the location without changing the href. I thought that was impossible, but obviously you're browser does understand it partly. I think the word 'partly' is your current problem .

It might be interesting that you can submit a from through js, using "formName.submit()".
That way you don't have to use an event handler like "formName.onSubmit", and you aren't bound to the dull old submit-button.

I'd say:

<a href="javascript:submitMyForm()">Submit-link</a>

function submitMyForm(){
document.getElementById('formName').submit();
location.href = 'www.whatever.com';
}

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 11-13-2002 16:07

Nevel:

When you use ~location~ by itself it defaults to ~location.href~

But I'm not sure how long it's been that way?

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 11-13-2002 16:13

Hmmm....

test page

In the SEARCH OTHER ZIP CODES form, enter any Michigan zip code, such as 48043. Press ENTER or click SUBMIT, and you'll go to the stats for that page, yet the address bar stays the same.

Here's what I'm using:
<script type="text/javascript" language="javascript">
function goto(zippy){
alert(zippy);
if (zippy != ""){
document.location.href='/stats/' + zippy + '/';
document.getElementById('zipsearch').submit();
}
}
</script>
<form name="zipsearch" method="post" action="" style="margin-top: 0px;" onsubmit="goto(zipsearch.zip.value);">

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 11-13-2002 17:30

http://homefiredesign.com/zipsearch.htm


Maybe?

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 11-13-2002 17:52

I seriously didn't know you could use a javascript call in the ACTION part of a form. That's cool - and it works! Thanks!

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 11-13-2002 18:22

Anytime.

« BackwardsOnwards »

Show Forum Drop Down Menu