• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Pre-populate fields with PHP from the URL

Pre-populate fields with PHP from the URL 12 years 9 months ago #18391

Hi there,

I'm wondering how to change a dropdown box's selection with a url parameter.

EG I have a dropdown box with these values

1|John Smith
2|Sue Smith
3|Peter Smith

and I want to get the value from the url and select it, eg:

www.somesite.com?name=2

Then when the page loads the dropdown box would select Sue Smith. I'm pretty sure this should be easy for a competent programmer, but I can't get there.

Either javascript or PHP is fine.

Any help would be greatly appreciated.

Thanks
The administrator has disabled public write access.

Pre-populate fields with PHP from the URL 12 years 1 month ago #22483

  • guido2011
  • guido2011's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
I have the same question.

Is this just not possible without scripting?
The administrator has disabled public write access.

Pre-populate fields with PHP from the URL 12 years 1 month ago #22484

  • guido2011
  • guido2011's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
I have the same question.

Is this just not possible without scripting or just too easy that this question is not answered?

Any comment would be nice.
Thankyou

note:
Found myself a nice working script. Gonna build it manualy.
Last Edit: 12 years 1 month ago by guido2011. Reason: Found a possible solution
The administrator has disabled public write access.

Pre-populate fields with PHP from the URL 12 years 1 month ago #22515

  • info4454
  • info4454's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
this snippet worked for me.
 
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  alert('Query Variable ' + variable + ' not found');
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!