/    Sign up×
Community /Pin to ProfileBookmark

Passing JS variable to others php pages

Does anyone know how I would get the chosen value from the second box onto another php form. Its a dynamic js drop box, the second box is populated by what is chosen in the first one.

<tr>
<th><label for=”bundle”><font color=”red”>*</font> Please select the bundle you require<br /> </th>
<td>
<select class=”textbundles” name=”adsl_example” size=”1″ onChange=”redirect(this.options.selectedIndex)”>
<option value=””>Please select an appropiate bundle</option>
<option>Single Business User ADSL</option>
<option>SOHO ADSL bundle (5-10 users)</option>
<option>SME ADSL bundle (5-15 users)</option>
</select>
</td>
<tr>

<th><font color=”red”>*</font> Please select a bandwidth speed<br />
If you wish to review these again please click <a href=”#”
alt=”Bundle Info”>here</a></td></label></th>

<td>
<select class=”textbundles” name=”adsl_stage2″ size=”1″>
<option value=””

SHOWBUNDLESDROPDOWN;
if( !isset($adsl_linetype)) echo “selected=”selected””;
print
<<<SHOWBUNDLESDROPDOWN
> Please select an option above first </option>
<option></option>
<option></option>
</select>
<input type=”hidden” name=”test” value=”Go!” onClick=”go()”>
</td>
<tr>
<script>
<!–
var groups=document.adsldetails.adsl_example.options.length;
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()

group[1][0]=new Option(“512kbps (¬£228 p.a. excluding VAT)*”,” “)
group[1][1]=new Option(“1Mbps (¬£348 p.a. excluding VAT)*”,” “)
group[1][2]=new Option(“2Mbps (¬£564 p.a. excluding VAT)*”,” “)

group[2][0]=new Option(“512kbps (¬£276 p.a. excluding VAT)*”,” “)
group[2][1]=new Option(“1Mbps (¬£396 p.a. excluding VAT)*”,” “)
group[2][2]=new Option(“2Mbps (¬£599 p.a. excluding VAT)*”,” “)

group[3][0]=new Option(“512kbps (¬£420 p.a. excluding VAT)*”,” “)
group[3][1]=new Option(“1kbps (¬£599 p.a. excluding VAT)*”,” “)
group[3][2]=new Option(“2Mbps (¬£899 p.a. excluding VAT)*”,” “)

var temp=document.adsldetails.adsl_stage2

function redirect(x){
for (m=temp.options.length-1;m>0;m–)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}

function go(){
location=temp.options[temp.selectedIndex].value
}

//–>
</script>

</td>
</tr>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@theuedimasterSep 26.2005 — Using javascript, change the value of a post variable in your form.

I think this page has a good explanation:

http://www.htmlgoodies.com/beyond/javascript/article.php/3471111
×

Success!

Help @solidariti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...