Forums

Add the result of the form to the url ?

alterna 20 Mar, 2010
Well I guess this is very simple to do but I cannot find the answer 😟

Let's say that I have a simple form with inputing just a number id {text} and sending it to my domain main page

I would like the form to add the id to like this mydomain/?r={text} and open it

I tried to put this in the submit or redirect url but it does not work. I also tried
mydomain/?r=<?php echo {text}?>


Could you help me ?
nml375 20 Mar, 2010
Hi,
Add the URL of your mainsite to the "submit URL", and set the method to "GET" instead of "POST".

/Fredrik
alterna 20 Mar, 2010
Thanks a lot... I knew it was something very simple😢
By the way how can I avoid to get also the button and the cfid code in my url ?
nml375 20 Mar, 2010
To remove the submit-button from the url, you'll have to edit your form code and remove the name property of the submit button. There's an option to disable the "token check" on the general tab, you'll have to turn this off, as this will add a randomly named hidden form field (the "token"). There is also a second token added by CF itself; 1cf1, to remove this, you'll have to edit some of the CF sources:
In chronocontact.html.php somewhere near line 184 you'll find a line like this:
<input type="hidden" name="1cf1" value="<?php echo $MyForm->generateCFToken($MyForm->formrow->name); ?>" />

That line would have to be removed.

One not-so-neat alternative would be to add '</form><form action="">' to the end of your form code, as this will end the form element before CF has any chance of adding the additional form fields..

/Fredrik
alterna 21 Mar, 2010
Wonderful, working perfectly well thanks :-)

Just one more thing, this is working ok on my iphone but I cannot input any number on firefox and got nothing in firebug.

If you have any idea or want to have a look, this is the search button of http://houah.com

I am only stuck at this and this would be ok

thanks anyway for the help so far
nml375 21 Mar, 2010
Well, it would seem the "maxlength" property for the input was set to 0, pretty much telling firefox and other more intelligent browsers that you can't enter anything there. Changing this to a larger value, or removing the property all together should allow you to enter some text into the textbox.

/Fredrik
alterna 21 Mar, 2010
Well this looks so simple when you know these things !!!
You saved me
Hope you will hear of my bubbles one day ! :-)
thanks and good night
alterna 21 Mar, 2010
One last little question:
I have also set up a form tag attachment onsubmit="getgoing();"

and I have the javascript function in my form:
function getgoing(){
window.open('http://mydomain/index.php?option=com_bulle&view=bulle&tmpl=component&referrer={r}','','width=250,height=250,location=no,scrollbars=no,menubar=no,resizable=no,toolbar=no,status=no');
}

I have tried {r} with or without php but it does not work to retrieve my field. I also tried $_GET with php but no success.

How could I do ?
GreyHead 21 Mar, 2010
Hi alterna,

If I understand correctly 'r' is set by an input in your form??

If so then PHP can't know the value before the form is loaded. You have to check the value of the input in your script and then add it to the url.

Bob
alterna 21 Mar, 2010

Hi alterna,

If I understand correctly 'r' is set by an input in your form??

...
Bob



yes !
I understand the problem with php. Could you tell me how to do it in javascript ? I don't know
Thanks
nml375 21 Mar, 2010
Hi,
Try something along these lines:
function getgoing() {
  window.open('http://mydomain/index.php?option=com_bulle&view=bulle&tmpl=component&referrer=' + encodeURIComponent(getElementsByName("r")[0].value), '', 'width=250,height=250,location=no,scrollbars=no,menubar=no,resizable=no,toolbar=no,status=no');
}


/Fredrik
alterna 21 Mar, 2010
Hi Fredrik thanks for helping

The code
 + encodeURIComponent(getElementsByName("r")[0].value
does not work.
When I enter a number the function is working ok though, but I cannot figure out how to get this damned "r" !πŸ™‚
nml375 21 Mar, 2010
Hi,
Sorry, made a typo... getElementsByName is a metod of the document object, so it should be:
... encodeURIComponent(document.getElementsByName("r")[0].value) ...


/Fredrik
alterna 21 Mar, 2010
Yes working very well this time !
Thanks a lot πŸ˜€
This topic is locked and no more replies can be posted.