/    Sign up×
Community /Pin to ProfileBookmark

Javascript & PHP Problem parsing input data:

This is what I use to go to .php when they change the info in the drop down field. I’ve noticed instead of parsing the data like a “submit formation, it just refreshes the page. Can I do this exact thing but state onchange, submit to file.php? Is this possible instead of just refreshing the data?

[code=php]
<tr>
<td width=”175″ height=”25″><font size=”2″># of Carts:</font></td>
<td width=”427″ height=”25″>
<select name=”Number_Of_Carts” onchange=”if(this.options[this.selectedIndex].id){top.location.href=this.options[this.selectedIndex].id;}return true;”>
<option selected></option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=1″ value=”1″>1</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=2″ value=”2″>2</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=3″ value=”3″>3</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=4″ value=”4″>4</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=5″ value=”5″>5</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=6″ value=”6″>6</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=7″ value=”7″>7</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=8″ value=”8″>8</option>
<option id=”mobile_vendors_pre_submit.php?state=<? $state = $_GET[‘state’]; echo $state; ?>&carts=9″ value=”9″>9</option>
</select>
</td>
</tr>
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Paul_JrSep 11.2004 — Assuming the Select element is within a form, and said form's action attribute points to the correct page;
<i>
</i>onchange="this.form.submit();"

However, you should also make sure the form works for users without JavaScript, so you could add something along the lines of:
<i>
</i>&lt;noscript&gt;
&lt;button type="submit"&gt;Submit Form&lt;/button&gt;
&lt;/noscript&gt;

Where you would want the submit button to appear.
Copy linkTweet thisAlerts:
@d_brandusaauthorSep 11.2004 — Okay, that works better, but it doesn't use the specified id"" url that I provided. How can I say onchange submit form with url provided in id based on what number they choose? If I can get that to work were set!
×

Success!

Help @d_brandusa 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.24,
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,
)...