Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using button to pass a path

Status
Not open for further replies.

dommett

Programmer
Apr 30, 2004
33
US
I have a form with two radio buttons (soon to be more). Each button has name="shop" but different values. I also have a hover button that calls a URL. Now what I need to do is change the path in the URL based on which radio button is selected. Any suggestions?

 

Any suggestions?

Many. As cLFlaVA says however, without seeing your code, it would be fruitless to suggest something as it may not integrate well.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
So sorry - here you go:

<form method="POST" action="--WEBBOT-SELF--" onSubmit="location.href='../_derived/nortbots.htm';return false;" webbot-onSubmit>
<!--webbot bot="SaveResults" u-file="../_private/form_results.csv" s-format="TEXT/CSV" s-label-fields="TRUE" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" endspan i-checksum="43374" -->
<p><input type="radio" value="Psephos" checked name="Store">Psephos Shopping Cart</p>
<p><input type="radio" name="Store" value="XeniaThrift">Xenia Thrift Store Shopping Cart</p>
</form>

<p>
<applet code="fphover.class" codebase="../" width="212" height="24">
<param name="textcolor" value="#FFFFFF">
<param name="hovercolor" value="#00FF00">
<param name="effect" value="glow">
<param name="color" value="#C0C0C0">
<param name="url" valuetype="ref" value="UploadImage.asp?Path="&***********form's radio button value*********&"&Type=cart">
<param name="text" value="Upload Shopping Cart Image">
</applet>&nbsp;&nbsp;&nbsp; <applet code="fphover.class" codebase="../" width="212" height="24">
<param name="textcolor" value="#FFFFFF">
<param name="effect" value="glow">
<param name="color" value="#C0C0C0">
<param name="hovercolor" value="#008080">
<param name="text" value="Shopping Cart Admin Control">
<param name="url" valuetype="ref" value="../comersus/backofficelite">
</applet></p>
 

Ouch - you didn't mention that a Java applet was involved... I was thinking a standard form button.

I'm not entirely sure if this will work or not, but give it a whirl. It it doesn't, you might consider using a stnadrd button (which will also work on browsers with Java disabled):

Code:
<p><input type="radio" value="Psephos" checked name="Store" [b]onclick="document.getElementById('myButton').url = 'pageA.html';"[/b]>Psephos Shopping Cart</p>
<p><input type="radio" name="Store" value="XeniaThrift" [b]onclick="document.getElementById('myButton').url = 'pageB.html';"[/b]>Xenia Thrift Store Shopping Cart</p>

...

<applet [b]id="myButton"[/b] code="fphover.class" codebase="../" width="212" height="24">

As I said, I have no idea if it will work, as I've never tried setting applet parameters like that.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
ok - to simplify things let's remove the applet. I just want radio buttons with a standard button that calls another asp file with the value of the selected radio button.
 
Code:
<input type="radio" name="blah" onclick="this.form.action=this.value;" value="page1.asp" />
<input type="radio" name="blah" onclick="this.form.action=this.value;" value="page2.asp" />

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
This seems to work except I actually need to send two variables in the URL ie:

value="page1.asp?Store=XeniaThrift&Type=Cart"

but when I try this, my URL ends up looking like this:


I tried making the form action="UploadImage.asp" and then the value of the radio button be "XeniaThrift&Type=cart" but I still get character conversion for the '&' symbol. How do I fix this?
 

You need to encode your ampersand, I'd say:

Code:
value="page1.asp?Store=XeniaThrift&amp;Type=Cart"

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
OK - new approach I found. Here is the code I have now:
Code:
<form>
<input type="hidden" name="gotolink" value="#"> 
<input type="radio" onClick="this.form.gotolink.value=this.value;" checked value="UploadImage.asp?Store=Pseohos&Type=cart" > Psephos
<BR><input type="radio" onClick="this.form.gotolink.value=this.value;" value="UploadImage.asp?Store=XeniaThrift&Type=cart" > Xenia Thrift 
<input type="button" value="Go!" onclick="document.location=this.form.gotolink.value;">
<form>
This looks like it will work ok except, it doesn't seem to let me click the second radio button. But - oddly enough, the value when I click the button is the second radio button's value. Anyone want to check my code to help me know what I'm doing wrong - please!!!
 

Neither of your radio buttons have names. For radio buttons to work correctly as a mutually exclusive set, they all need to have the same name.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top