Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Populating A Form From A Link

Recommended Posts

I have an online application Form that multiple groups use from their own webpages. I would like the form to automatically populate a couple fields depending on which group's site it's clicked from......... I think there is a way to populate a form just by adding stuff to the link, but I don't know how and I can't find any information on how online (not really sure what to search)......... anyone know? I want a combo-box and a text field automatically populated with information depending on the link that's clicked.I honestly don't know if this is an HTML thing or a Javascript thing... if need be I'll go ask on the Javascript forum instead.Thanks!

Share this post


Link to post
Share on other sites

It sounds like you're talking about using the querystring to pass variables to your form. So your link would be something like link.php?id=X&somevalue=Y&someothervalue=Z.

Then you use $_GET or $_REQUEST to access the variables and then print them to your form.

Share this post


Link to post
Share on other sites

I was searching for something similar...i need some help[ as well..Tyseen i dont get what you mean? The page my form is on a HTML file not a php..and yeah i donjt understand what you mean

Share this post


Link to post
Share on other sites

That's going to be a javascript work, but I reccommend PHP more. Xisto supports PHP why not use it? It's not that hard to work with PHP, you'll end up using PHP to process the form anyway. So why not using php for the form.Another thing is you said from a "link". Different links can point to different pages can't it, so why combine it to the same page?

Share this post


Link to post
Share on other sites

You can't achieve this sort of thing without some sort of scripting whether it be PHP, ASP or javascript (not as straightforward in JS anyway I think). Your form will be output to the browser as HTML, but you can use a script to construct that HTML and fill in the values.

So, taking the previous example, the link to the form is link.php?id=X&somevalue=Y&someothervalue=Z.

Using PHP, you'd do something like this:

 

<?php print '<input type="text" name"field1" id="field1" value="'.$_GET('somevalue').'" />print '<input type="text" name"field2" id="field2" value="'.$_GET('someothervalue').'" /> ?>

Share this post


Link to post
Share on other sites

I think what you want is that if you select an option in the very form, like a select, other stuff beneath it will get some info, i have something like that... let me get it:

<select name="acompa" id="acompa" onchange="if(acompa.selectedIndex==1)nombre_acompa.disabled=false; else{nombre_acompa.disabled=true; nombre_acompa.selectedIndex=0}">        <option value="0">-----</option>        <option value="1">yes</option>        <option value="2">no</option>      </select>

Where nombre_acompa is the field that you want to block, or unblock.I know that you want to actually populate the fields, not block them or unblock them, but you can use this principle and apply this:document.form.nombre_acompa.value == "text to be set"In the 'onchange' javascript event.This would not be valid xhtml 1.0 strict though. (I think there's no "onchange" attribute =P )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.